Back to product page

Embed Method


Adds new embedded image to the message.

Type

A String value. CID that should be referenced from HTML part, usually in <IMG SRC=...> tag.

Syntax

  • Basic
object.Embed (Filename, ContentType, Encoding)
The Embed(object,Filename,ContentType,Encoding) syntax has these parts:
objectAn expression evaluating to an object of type SmtpMsg
FilenameRequired. A String value. File on your disk you want to embed to the message.
ContentTypeOptional. A Variant value. Specifies Content-Type header value.
EncodingOptional. A Variant value. Specifies preferred encoding type (base64 is default).

Remarks

Embedding images to the message is very similar to adding attachments - except header values describing that attachments are slightly different. Each embedded image has corresponding Content-ID value that you reference from the message body later on.

Please note that wodSmtp may do significant changes on your message if you use this method. First, it has to determine if message is already multipart (which is needed to have embedded images). If not, it will create appropriate headers (by default this will be 'Content-type: multipart/related'), choose boundary to use for parts separation, create new message part, and add encoded image to the message.

Using this scenario, it's easy for you to embed image to the message, with a simple snippet like this:
Dim cid as String
cid = wodSmtp.Message.Embed ("myimage.gif", "image/gif")
wodSmtp.Message.HTMLText = "..........."

What happens to the message file after Embed is called? wodSmtp creates temporary file, adds one header 'Content-ID', and return it's value. You can use that value in HTML body for <IMG SRC=...> tag.

Make sure you set ContentType argument properly, otherwise image will not be displayed correctly. For GIF images, you should set image/gif, and for JPEG images you should set image/jpeg.

If you wish to provide image directly from String instead of having it in local file, please check EmbedText method.

Platforms

Windows