Home     Products      Support      Corporate     Sign In 
Support Knowledge Base, Article 953
Embedded image support in SMTPMail
Can I embed images into an HTML email using SMTPMail?

SMTPMail does not support embedded images in an HTML email, but it does support inline images sent as attachments and inline images stored on a website.

Directly embedded images

HTML emails normally allow embedded images that are stored as objects hidden from view of the recipient, and are referenced from the message body of the email in a syntax similar to this example:

<img id="_x0000_i1025" src="cid:image001.gif@01C4890D.EE6B3500">

SMTPMail does not support this feature, but it does support two common alternatives:

  1. Images as attachments
  2. Images stored on a website

Alternative 1 - Images as attachments

You can call AddAttachment() for each image you want to display in an email and then reference the images from the message body like this:

<img src="image001.gif">

Here is an example of an attached image:

Set Mailer = Server.CreateObject("SoftArtisans.SMTPMail")
'--- Set the Sender's information
Mailer.FromName   = "Someone"
Mailer.FromAddress = "someone@somewhere.com"	

'--- Set the Remote Host server
Mailer.RemoteHost = "mailserver"
'--- Add the recipient who will receive the email.
Mailer.AddRecipient "someoneelse@nowhere.com"

'--- Sets Subject line for the message  
Mailer.Subject = "Email with an image"

'--- Attach file(s)
Mailer.AddAttachment Server.MapPath("./image001.gif")
'--- Body of text 
Mailer.BodyText = "This is an email with an attached image."

Mailer.HTMLText = "This is an email with an attached image. " & _
         "Here is the image: <img src=""image001.gif"">"

'--- Sends the message and can be used to verify if there if it has been sent.
If Mailer.SendMail then
	Response.Write "Mail sent...<br>"
	Response.Write "Mail send failure. <br>"
End If
'--- Clean Up
Set Mailer = nothing

Alternative 2 - Images stored on a website

SMTPMail also supports a commonly used third option for displaying images in an HTML email. You can display an image hosted on a website. In this case you would not need to add the image as an attachment to an email. An example of this would be as follows:

Mailer.HTMLText = "This is an email with an attached image. " & _
         "Here is the image: <img src=""http://www.mydomain.com/images/image001.gif"">"
Created : 10/6/2004 2:46:26 PM (last modified : 10/6/2004 2:46:26 PM)
Rate this article!