Catalyst Internet Mail .NET

Styled Message Text

To send an e-mail message that contains styled text using HTML formatting, the ComposeMessage method can be used, similar to how plain text messages are sent. For example, consider the following message contents:

<html>
<head></head>
<body>
<font face="Arial">
<h3>Test HTML Message</h3>
This is a test message which uses HTML to format the text. This
message was created using the <b>Internet Mail</b> control from
<a href="http://www.catalyst.com/">catalyst Development</a>.
</font>
</body>
</html>

You could either assign this text to a string, or you could read the message from a file. To compose the HTML formatted e-mail, simply call the ComposeMessage method as you would with a plain text message, except that you also specify the MessageHTML argument. For example, your code might look like this:

InternetMail1.ComposeMessage(editFrom.Text, _
                             editTo.Text, _
                             editCc.Text, _
                             editBcc.Text, _
                             editSubject.Text, _
                             strMessageText, _
                             strMessageHTML)

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 InternetMail component makes this easy to do.