How to send plain text emails that are HTML formatted?
A nice feature
of modern email programs is that you can send and receive email that is formatted
using HTML commands, containing text and images- and sometimes even JavaScript
code for animations and the like. If you want to create such messages on your
Web server, this is no problem because CDONTS supports the creation of HTML messages.
A sample email with an attached image is presented here.
The
major part of this listing deals with creating the appropriate HTML text. It is
standard HTML, and line 17 even includes an image. When you add images to your
HTML message, you must change the mail and body format of your email message.
The necessary changes are made in the lines 25 and 26
objMail.Bodyformat
= 0 objMail.Mailformat = 0
The
body format determines whether the message is plin text (1) or can contain HTML
(0). Next you must determine the mail format, which describes how the mail is
composted: it can be either a text message (1) or a MIME formatted (0) message.
When you attach files, you should use the MIME type, which leads to the final
new statement in this example:
when
using an image in the HTML message, you must specify its physical path as well
as URL path that can be used in the message (<IMG> tag) to refer to it.
By sending the email on line 31 using the well-known send method, it is on the
way to the destination address.