|

DOWNLOAD
Reference
Chilkat Log Reference
Versions
MHTML Features
Chilkat Mail makes it easy to send and receive HTML
formatted emails with embedded, internally referenced images.
The standard way of doing this is to format emails using a MIME
content type called "multipart/related". Chilkat Mail
does this for you, and you don't have to know anything about the
structure of "multipart/related" MIME messages. (For
those that do, Chilkat Mail does handle "multipart/alternative"
messages contained within "multipart/related". If fact,
ChilkatMail can handle messages of any complexity.)
Sending a HTML email with an image:
Here is an example of creating and sending an email
that has an HTML body, and references an internal image.
Dim mailman As Object
Set mailman = CreateObject("ChilkatMail.ChilkatMailMan")
' Get the free unlock-code from http://www.chilkatsoft.com
mailman.UnlockComponent "unlock-code"
mailman.SmtpHost = "my.smtpserver.com"
Set email = New ChilkatEmail
email.AddTo "Bill Yahoo", "yahoo@chilkatsoft.com"
email.Subject = "Here is some HTML with an image."
email.Body = "This is an email from Chilkat Software."
email.From = "fausey@chilkatsoft.com"
' Add an image
contentID = email.AddRelatedContent("sample.gif")
' Set the email body, and reference the image
htmlBody = "<HTML><HEAD></HEAD><BODY><br>"
htmlBody = htmlBody & "This is an example of embedding an image in HTML email."
htmlBody = htmlBody & "<BR><IMG SRC=" & Chr(34) & "cid:" & contentID & Chr(34)
htmlBody = htmlBody & "><br><br></BODY></HTML>"
email.SetHtmlBody htmlBody
mailman.SendEmail email
Set email = Nothing
Set mailman = Nothing
Sending a HTML email with an image and also with
a plain-text alternative for Email clients that cannot accept
HTML:
Just modify the code above by adding this line:
email.AddPlainTextAlternativeBody "This is the plain-text body"
This line can be added anywhere after the email
is created, but before it is sent.
Sending a HTML email with an image, an MS-Word
file attachment, and also with a plain-text alternative:
Just modify the code above by adding this line:
email.AddFileAttachment "sampleWordDoc.doc"
This line can be added anywhere after the email
is created, but before it is sent.
If you created an email with related content, a
plain-text alternative, and an attached file, the MIME that would
be created is a "multipart/alternative" within a "multipart/mixed"
within a "multipart/related". ChilkatMail can send and
receive emails this complex. Microsoft Outlook can handle it.
But many email clients are not sophisticated enough to handle
such a beast, however properly formatted it happens to be. (The
point here is that even though ChilkatMail can handle something
very complex, many mail clients won't.)
|