What is the namespace used for sending mails

Use System.Web.Mail The System.Web.Mail namespace contains classes that enable you to construct and send messages using the CDOSYS (Collaboration Data Objects for Windows 2000) message component. The mail message is delivered either through the SMTP mail service built into Microsoft Windows 2000 or through an arbitrary SMTP server. The classes in this namespace can be used from ASP.NET or from any managed application. For more details refer System.Web.Mail Namespace

How do I email a website exception

VB.NET Protected Sub Application_Error(sender As [Object], e As EventArgs) Dim ex As Exception = Server.GetLastError() Dim mail As New MailMessage() mail.To = ‘[email protected]’ mail.From = ‘[email protected]’ mail.Subject = ex.Message.ToString() mail.Body = ex.ToString() mail.BodyFormat = MailFormat.Html SmtpMail.SmtpServer = ‘localhost’ SmtpMail.Send(mail) End Sub ’Application_Error C# protected void Application_Error(Object sender, EventArgs e) { Exception ex = Server.GetLastError (); MailMessage mail = new MailMessage(); mail.To = ‘[email protected]’; mail.From = ‘[email protected]’; mail.Subject = ex.Message.ToString (); mail.Body =ex.ToString (); mail.BodyFormat = MailFormat.Html; SmtpMail.SmtpServer = ‘localhost’; SmtpMail.Send( mail ); }

How do I send non US-ASCII mails

VB.NET mail.BodyEncoding = System.Text.Encoding.GetEncoding( ‘ISO-2022-JP’ ) C# mail.BodyEncoding = System.Text.Encoding.GetEncoding( ‘ISO-2022-JP’ );

How do I send a web page?

Use namespace System.IO and System.NET VB.NET ’In Page_Load Dim mailcontenturl As String = ‘http://www.syncfusion.com’ Dim mail As New MailMessage() mail.To = ‘[email protected]’ mail.From = ‘[email protected]’ mail.Subject = ‘Test.’ ’To send webpage mail.Body = GetHTML(mailcontenturl) mail.BodyFormat = MailFormat.Html mail.UrlContentBase = mailcontenturl SmtpMail.SmtpServer = ‘localhost’ SmtpMail.Send(mail) ’Function GetHTML Private Function GetHTML(url As String) As String Dim wReq As WebRequest = System.Net.HttpWebRequest.Create(url) Dim sr As New StreamReader(wReq.GetResponse().GetResponseStream()) Dim result As String = sr.ReadToEnd() sr.Close() Return result End Function ’GetHTML C# //In Page_Load string mailcontenturl =’http://www.syncfusion.com’; MailMessage mail = new MailMessage(); mail.To = ‘[email protected]’; mail.From = ‘[email protected]’; mail.Subject = ‘Test.’; //To send webpage mail.Body = GetHTML ( mailcontenturl ); mail.BodyFormat = MailFormat.Html; mail.UrlContentBase = mailcontenturl; SmtpMail.SmtpServer = ‘localhost’; SmtpMail.Send( mail ); //Function GetHTML private string GetHTML( string url ) { WebRequest wReq= System.Net.HttpWebRequest.Create(url); StreamReader sr = new StreamReader( wReq.GetResponse().GetResponseStream() ); string result = sr.ReadToEnd(); sr.Close(); return result; }

How to send HTML mail in ASP.NET

VB.NET Dim mail As New MailMessage() mail.To = ‘[email protected]’ mail.From = ‘[email protected]’ mail.Subject = ‘Test.’ mail.BodyFormat = MailFormat.Html mail.Body = ‘Test Message’ SmtpMail.SmtpServer = ‘localhost’ ’your real server goes here SmtpMail.Send(mail) C# MailMessage mail = new MailMessage(); mail.To = ‘[email protected]’; mail.From = ‘[email protected]’; mail.Subject = ‘Test.’; mail.BodyFormat = MailFormat.Html; mail.Body = ‘Test Message’; SmtpMail.SmtpServer = ‘localhost’; //your real server goes here SmtpMail.Send( mail );