System.Web.Mail FAQ

Complete FAQ Listing


2.2 How do I send a simple Html email? Printer Friendly   Email This FAQ   Discuss

By default, email sent with System.Web.Mail is formatted as plain text. To format as Html, set the MailMessage.BodyFormat property to MailFormat.Html.
 
[ C# ]
MailMessage mail = new MailMessage();
mail.To = "me@mycompany.com";
mail.From = "you@yourcompany.com";
mail.Subject = "this is a test email.";
mail.BodyFormat = MailFormat.Html;
mail.Body = "this is my test email body.<br><b>this part is in bold</b>";
SmtpMail.SmtpServer = "localhost";  //your real server goes here
SmtpMail.Send( mail );

[ VB.NET ]
Dim mail As New MailMessage()
mail.To = "me@mycompany.com"
mail.From = "you@yourcompany.com"
mail.Subject = "this is a test email."
mail.BodyFormat = MailFormat.Html
mail.Body = "this is my test email body.<br><b>this part is in bold</b>"
SmtpMail.SmtpServer = "localhost" 'your real server goes here
SmtpMail.Send(mail)

 

Discuss This FAQ Item
Got a question? Another Suggestion? Want to post your solution? Discuss it below.
New Post
  • mail.To    [ Reply ]
    • RE: mail.To    [ Reply ]
      • RE RE: mail.To    [ Reply ]
    • RE: mail.To    [ Reply ]
    • RE: mail.To    [ Reply ]
    • RE: mail.To    [ Reply ]
    • RE: mail.To    [ Reply ]
    • RE: mail.To    [ Reply ]
    • RE: mail.To    [ Reply ]
  • HTML View warning    [ Reply ]
  • HTML View warning    [ Reply ]
  • HTML View warning    [ Reply ]
  • HTML View warning    [ Reply ]
  • Arabi mail    [ Reply ]
    • RE: Arabi mail    [ Reply ]
      • RE RE: Arabi mail    [ Reply ]
      • RE RE: Arabi mail    [ Reply ]
        • RE: RE RE: Arabi mail    [ Reply ]
          • RE RE: RE RE: Arabi mail    [ Reply ]
      • RE RE: Arabi mail    [ Reply ]
  • Problem in sending mail to yahoo or hotmail    [ Reply ]
  • HTML BodyFormat not working    [ Reply ]
    • RE: HTML BodyFormat not working    [ Reply ]
    • RE: HTML BodyFormat not working    [ Reply ]
      • RE RE: HTML BodyFormat not working    [ Reply ]
  • Mail being filtered as Junk from asp.net page    [ Reply ]
  • CDONTS Problem    [ Reply ]
    • RE: CDONTS Problem    [ Reply ]
      • RE RE: CDONTS Problem    [ Reply ]
  • EMail SPAM    [ Reply ]
  • Problem with html    [ Reply ]
    • RE: Problem with html    [ Reply ]
    • RE: Problem with html    [ Reply ]
  • I want to send mail with my selected font and colors    [ Reply ]
  • HTML BODY    [ Reply ]
    • RE: HTML BODY    [ Reply ]
  • problems setting to html    [ Reply ]
    • RE: problems setting to html    [ Reply ]
  • emailing    [ Reply ]
  • getting error in code of sending email using VB.NET    [ Reply ]
  • Could not access CDO.message object    [ Reply ]
    • RE: Could not access CDO.message object    [ Reply ]
  • Missing blanks sending HTML test    [ Reply ]
  • send hyperlinks through mail which will open in same browser instance    [ Reply ]
  • Want to send an image in the body of mail    [ Reply ]
  • SMTP Server    [ Reply ]
  • Problem: HTML email body and encoded attachment    [ Reply ]
  • E-Mail not receiving in Inbox that sent from asp.net page    [ Reply ]
  • url    [ Reply ]
    • RE: url    [ Reply ]
  • hai...    [ Reply ]
  • HTML Body not proper    [ Reply ]
  • how do i send a html email with img src    [ Reply ]
  • vb.net    [ Reply ]
  • vb.net    [ Reply ]
  • How to Encode the Email Body to Base64    [ Reply ]
    • RE: How to Encode the Email Body to Base64    [ Reply ]
  • Hyperlink in the Email body    [ Reply ]
  • I want to send mail in HTML Format    [ Reply ]
  • I want to send mail in HTML Format    [ Reply ]
    • RE: I want to send mail in HTML Format    [ Reply ]
  • Mail Status    [ Reply ]
    • RE: Mail Status    [ Reply ]
      • RE RE: Mail Status    [ Reply ]
      • RE RE: Mail Status    [ Reply ]
  • how can i send html page with images    [ Reply ]
    • RE: how can i send html page with images    [ Reply ]
  • Sending an e-mail with text underlined    [ Reply ]
    • RE: Sending an e-mail with text underlined    [ Reply ]
  • doubt    [ Reply ]
  • sending a mail in asp.net    [ Reply ]
    • RE: sending a mail in asp.net    [ Reply ]
  • Format issue with rediff email    [ Reply ]
  • voting buttons    [ Reply ]
  • Error Sending HTML Mail    [ Reply ]
    • RE: Error Sending HTML Mail    [ Reply ]
  • getting server error    [ Reply ]
    • RE: getting server error    [ Reply ]
  • Email with table    [ Reply ]
  • hi    [ Reply ]