aspNetEmail

EmailMessage.HtmlBodyPart Property

The HTML mime body part of a Multi-Part email.

public string HtmlBodyPart {get; set;}

Remarks

This property will retrieve or set the HTML body of a multi-part email. This property achieves the same functionality as creating a MimeBodyPart, setting it’s BodyFormat= MailFormat.Html, and adding the part using AddMimeBodyPart(). If HtmlBodyPart is set to null, that body part will be removed from the collection. Do not mix the Body property with the TextBodyPart and HtmlBodyPart properties. If the HtmlBodyPart is set without a TextBodyPart, a TextBodyPart will be created from the HtmlBodyPart text.

Example

[C#]
		EmailMessage msg = new EmailMessage( "mail.mycompany.com");
		msg.FromAddress = "me@mycompany.com";
		msg.To = "you@yourcompany.com";
		msg.Subject="multi-part email";
		msg.AltText = "This is a multi-part email in Mime format.";
		msg.TextBodyPart = "This is the text that will be shown to email clients that do not support html formatted emails.";
		msg.HtmlBodyPart = "<h3>Hello</h3><p>This part of the email will be rendered in clients that DO support html formatted emails</p>";
		msg.Send();
		
		
[Visual Basic]
		Dim msg As EmailMessage = New EmailMessage("mail.mycompany.com")
		msg.FromAddress = "me@mycompany.com"
		msg.To = "you@yourcompany.com"
		msg.Subject = "multi-part email"
		msg.AltText = "This is a multi-part email in Mime format."
		msg.TextBodyPart = "This is the text that will be shown to email clients that do not support html formatted emails."
		msg.HtmlBodyPart = "<h3>Hello</h3><p>This part of the email will be rendered in clients that DO support html formatted emails</p>"
		msg.Send()
		
		

See Also

EmailMessage Class | aspNetEmail Namespace | TextBodyPart | MimeBodyPart