1. Introduction 2. Getting Started 3. Attachments 4. Embedded Images 5. Security 6. Unicode 7. Queuing Part I 8. Queuing Part II Object Reference |
Chapter 4. Embedded Images
Linked vs. Embedded Images
Linked images are not part of the message itself. They are usually hosted by the message
sender and referenced in the message body via an <IMG> tag pointing
to the sender's server, as follows:
<IMG SRC="http://www.sender-company.com/images/flower.jpg">
The main advantage of linked images is that the message body remains small. The main disadvantages
are that such messages cannot be viewed off-line, and they have a limited
lifespan (images on the sender's server may be moved, deleted, or the server itself
may go offline).
Unlike linked images, embedded images are part of the message itself.
They are similar to regular attachments,
although they use the multipart/related format,
as opposed to multipart/mixed. An embedded image
is also referenced in a message body using an <IMG> tag,
but instead of a URL, an image identifier, or Content ID, is used, as follows:
<IMG SRC="cid:My-Image-Identifier">
A message with embedded images can be viewed off-line and remains
intact over time, as images are permanently attached to the body.
A message may contain regular attachments and embedded images at the same time.
The AddEmbeddedImage Method
The following example uses the file margin.gif (included with the component)
as the background image for a message (note that here we use the BACKGROUND attribute
of the <BODY> tag instead of <IMG>):
...
In a similar manner, you can embed a sound file in your message using the
<BGSOUND> tag, for example:
Mail.Body = "<HTML><BGSOUND=""cid:My-Sound""></BGSOUND>...</HTML>"
Note: Content-IDs are case-sensitive. Make sure the values specified by
"cid:..." and AddEmbeddedImage fully match.
To make your script more readable, you may choose to place your message body
in a separate file and import it into the Body property using the
method AppendBodyFromFile which accepts a full path to the text or
HTML file containing the message body. A body file may look as follows:
The following code sample demonstrates
the usage of AddEmbeddedImage and AppendBodyFromFile:
If Request("Send") <> "" Then
' message subject
' Add embedded image for background
' Add embedded image for logo
Mail.Send ' send message
Click the links below to run this code sample:
http://localhost/aspemail/EmbeddedImages/EmbeddedImages.asp
The AddEmbeddedImageMem Method
Copyright © 1999 - 2003 Persits Software, Inc. All Rights Reserved Questions? Comments? Write us! |