MailMessage.AlternateViews Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

clsCompliantAlternativenone

Gets the attachment collection used to store alternate forms of the message body.

Namespace:   System.Net.Mail
Assembly:  System (in System.dll)

Public ReadOnly Property AlternateViews As AlternateViewCollection

Use the AlternateViews property to specify copies of an e-mail message in different formats. For example, if you send a message in HTML, you might also want to provide a plain text version in case some of the recipients use e-mail readers that cannot display HTML content.

To add an alternate view to a MailMessage object, create an Attachment for the view, and then add it to the collection returned by AlternateViews. Use the Body property to specify the text version and use the AlternateViews collection to specify views with other MIME types. Use the MediaTypeNames class members to specify the MIME type for the alternate view.

The following code example demonstrates creating and sending an e-mail message with a plain text and an HTML alternate view.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 2.0
Return to top
Show: