| Sending HTML Messages | ||
|
To send an HTML formatted e-mail message, the ComposeMessage method can be used, similar to how plain text messages are sent. For example, consider the following HTML text:
You could either assign this text to a string, or you could read the message from a file using code like this:
Where strMessageFile contains the HTML message you wish to send. To compose the HTML formatted e-mail, simply call the ComposeMessage method as you did with the plain text message, except that instead of passing the message to the MessageText argument, you pass it to the MessageHTML argument:
The message that will be sent will now be displayed to the recipient using HTML and will include the formatting (such as font and text size) as well as the hyperlink. However, not all mail clients are capable of displaying HTML e-mail. This poses a problem because the message that they'll receive will be the largely unreadable HTML source. To resolve this problem, create both a plain text version of the message along with the HTML version. Ideally it would contain similar content, although you could provide a simple message which says that this is an HTML e-mail and they should request a plain-text version if they can't display HTML messages. In either case, simply provide both the MessageText and MessageHTML arguments:
This will create what is called a multipart/alternative MIME message which contains both plain text and HTML versions of the message. Mail clients which are capable of displaying the HTML message will use that version, while those that cannot will display the plain text version. It should be noted that there are still some mail clients which do not understand multipart/alternative messages and therefore will display both the plain text and the HTML source text. While confusing, the plain text version will ensure that the message is still readable. For the most part, e-mail is still a plain text medium so if you consider readability and compatibility with older mail software to be more important than formatted text, it is recommended that you use only plain text messages. However, if you know that the recipients have mail clients that are capable of displaying HTML, the Internet Mail control makes this easy to do. |
||
|
Copyright © 2008 Catalyst Development Corporation. All rights reserved. |
||