|

DOWNLOAD
Reference
ASP Examples
Visual Basic Examples
Chilkat Mail Example:
Send an HTML Email with an Embedded Image
This example demonstrates how to create and send
an HTML Email programmatically, attach an image file, and embed
it within the HTML. Mail clients such as Outlook or Eudora will
display the image and HTML properly.
IMPORTANT: If Chilkat Mail
and Chilkat WebMail are separate components.
If you are using Chlilkat WebMail, the code is the same, but the
names of the components created are different. Use CreateObject("ChilkatWebMail.WebMailMan")
instead.
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<TITLE>Mail HTML with Embedded Image Example</TITLE>
</HEAD>
<BODY>
<%
' Create a mailman
set mailman = Server.CreateObject("ChilkatMail.ChilkatMailMan")
' Get the UnlockCode free from http://www.chilkatsoft.com
mailman.UnlockComponent "unlock-code"
' Tell the mailman where the SMTP server is located
mailman.SmtpHost = "localhost"
' Create an Email message
set email = Server.CreateObject("ChilkatMail.ChilkatEmail")
' Enter the recipient's information
email.AddTo "Bill Yahoo", "fausey@localhost"
' Enter the sender's information
email.FromName = "Joe Smith"
email.FromAddress = "joe.smith@somedomain.com"
' Enter the email subject
email.Subject = "Here is an image in HTML"
imageContentID = email.AddRelatedContent("c:\inetpub\wwwroot\images\sample.jpg")
' Enter the email text
email.SetHtmlBody ("<HTML><HEAD></HEAD><BODY>"& _
"<br>This is an example of embedding an image in HTML email.<BR><IMG SRC="& _
chr(34)&"cid:"&imageContentID&chr(34)& _
"><br>The content ID of the image looks like this: "& _
imageContentID&"<br>The HTML for embedding the image looks like this: <img src="& _
chr(34)&"cid:"&imageContentID&chr(34)&"><br></BODY></HTML>")
' Sends the email with the patterns replaced.
if mailman.SendEmail(email) then
Response.write "Message sent successfully!<br><br>"
else
Response.write "ERROR: Message not sent!<br><br>"
end if
' Standard ASP cleanup of objects
Set email = Nothing
Set mailman = Nothing
%>
</BODY>
</HTML>
|
|