|

DOWNLOAD
Reference
ASP Examples
WebMail 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.
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<TITLE>Mail HTML with Embedded Image Example</TITLE>
</HEAD>
<BODY>
<%
' Create a mailman
set mailman = Server.CreateObject("ChilkatWebMail.WebMailMan")
' Unlock the component - use your trial or purchased unlock code.
mailman.UnlockComponent "unlock_code"
' Tell the mailman where the SMTP server is located
mailman.SmtpHost = "localhost"
' Create an Email message
set email = Server.CreateObject("ChilkatWebMail.WebEmail")
' Enter the recipient's information
email.AddTo "John Smith", "jsmith@chilkatsoft.com"
' 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
%>
<br>(View page source to see the log)
<XML ID="XMLID">
<%
Response.write mailman.GetInstanceLog()
%>
</XML>
<%
' Standard ASP cleanup of objects
Set email = Nothing
Set mailman = Nothing
%>
</BODY>
</HTML>
|
This ASP Script demonstrates how to embed an image in an HTML
Email and send it.
|
Privacy
Statement. Copyright 2000-2009 Chilkat
Software, Inc. All rights reserved.
Send feedback to support@chilkatsoft.com Components for Microsoft Windows XP, 2000, 2003 Server, Vista, and Windows 95/98/NT4.
|
|