wodSmtp ActiveX Control - Embed Method
      
 

Description

Adds new embedded image to the message.


Return Type

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


Syntax

object.Embed (Filename, [ContentType], [Encoding])



The Embed Method syntax has these parts:

Part Description
object An expression evaluating to an object of type SmtpMsg.
Filename Required. A String value. File on your disk you want to embed to the message.
ContentType Optional. A Variant value. Specifies Content-Type header value.
Encoding Optional. 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 = "<HTML>.......<img src=""" & cid & """>....</HTML>"

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.