Monday, July 18, 2005

How to make HTML E-Mail with embedded images

Many HTML based e-mails have images linked to the world wide web. While the size is compact, but there are the following drawbacks:

1. The linked object/image may be deleted in the future, such that the the content of the e-mail will not be archived.
2. The E-Mail reader may not have Internet access at the time reading the e-mail (off-line reading case.)

If we can make the images embedded into this HTML file and make this HTML file self-contained, then we will not need to worry about the availability of the image and the availability of the Internet. This is particular important if you want to keep a news story happened two years ago with pictures .

You can implement this by using CDONTS (NT/2000) or CDOSYS(2000/2003 Server).

In CDONTS:
If we have a image source = logo.gif, then we will need to use the following code to include this Logo to our e-mail:
Set eMailObj = Server.CreateObject("CDONTS.NewMail")
eMailObj.BodyFormat = 0
eMailObj.MailFormat = 0
eMailObj.Body = ......... 'html code with Img Src of Logo.gif
eMailObj.AttachURL MapPath("Logo.Gif"), "Logo.gif"
eMail.Obj.Send

In CDOSYS:

Set iMsg = Server.CreateObject("CDOSYS.Message")
'prepare strHTML and make Img Src Login.gif
iMsg.HTMLBody = strHTML

iMsg.AddRelatedBodyPart MapPath("Logo.gif"), "Logo.gif", cdoRefTypeId 'cdoRefTypeID = 0

iMsg.Send

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home