Allows adding an alternate view of the message that provides richer content. For example you may configure the main message as plain text and the alternate view as html including embedded images that are stored as part of the message.
AlternetViews should be used only if you need to create more than two different alternate views, or if you want to embed images directly into the message content itself for self-contained image messages without external links.
For example the following creates a simple message that has only a text marker for non-HTML clients and an HTML alternate view that contains a rich message and an embedded image to display in the message:
loSmtp.cSubject = "Test Message through wwIPstuff" loSmtp.cMessage = "This message contains rich text content as an alternate view" loSmtp.cContentType = "text/plain" LOCAL loAlternateView as wwSmtpAlternateView loAlternateView = CREATEOBJECT("wwSmtpAlternateView") loAlternateView.cText = "<b>Hello</b> World! <img src='cid:sailbig' />" loAlternateView.cContentType = "text/html" loAlternateView.AddLinkedResource("c:\sailbig.jpg","image/jpeg","sailbig") loSmtp.AddAlternateView( loAlternateView )
In this scenario any mail client that does not understand the main content type (text/html) will display the alternate view which is just plain text.
Alternate views can also embed linked resources - that is resources that are embedded as part of the message and display inline of the message. By creating an wwSmtpAlternateView class and setting cText, cContentType on this object and then adding a linked resource this linked resource can be embedded directly into the message.
Linked Resources are added with a file path, a MIME content type and a resource Id (in this case 'sailbig'). This resource id can then be embedded and linked from the message text by using:
<img src="cid:sailbig" />
inside of the message text.
An instance of the wwSmtpAlternateView class.
The class has the following properties and methods:
The text of the alternate view message.
The content type of the message. Default is plain/text, but common is text/html for rich content.
AddLinkedResource(lcFilename, lcContentType, lcContentId)
This method adds a related resource 'attachment' that is treated as an embedded resource that can be referenced from the cText property's html. Use
<img src="cid:<resourceId>" /> to embed an image resource into the message.
This feature only work with the .NET version of wwSMTP (
nMailMode = 0).
Important: Although this feature is available the recommended way to get rich content to display is to use an HTML primary message text and link images from the Web into the message rather than embedding images directly into the email. This reduces mail traffic drastically.
Additionally keep in mind that not all mail clients support the embedded format, but most nowadays do support HTML messages.
Finally note that 'preview' displays in Outlook display the main message plain text, and the alternate view when the message is opened. This may or may not be desirable. Spend some time checking out how mail clients display this mixed content.
See also:Class wwSMTP
Comment or report problem with topic