|

DOWNLOAD
Reference
ASP Examples
Visual Basic Examples
Chilkat Mail Example
Forward all the Emails Found in a Zip to
Another Recipient
This example example opens a Zip file containing
Emails, replaces the recipient with another email address, and
forwards each email.
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>Chilkat Mail Example: Read and display emails from a Zip file.</TITLE>
</HEAD>
<BODY>
Reading email from a Zip file....<br><br>
<%
' Create a mailman
set mailman = Server.CreateObject("ChilkatMail.ChilkatMailMan")
' Get the UnlockCode free from http://www.chilkatsoft.com
mailman.UnlockComponent "mailman-unlock-code"
' Tell the mailman where the SMTP server is located
mailman.SmtpHost = "mail.some_server.com"
' Create a new Zip file.
' (This must be Chilkat Zip version 4.0 or greater)
set zip = Server.CreateObject("ChilkatZip.ChilkatZip")
' Insert the call to UnlockComponent if the Zip component is licensed.
zip.UnlockComponent "zip-unlock-code"
' Open the Zip file.
zip.OpenZip "c:\email\zips\email.zip"
' Create an empty mail bundle.
Set mailBundle = Server.CreateObject("ChilkatMail.ChilkatEmailBundle")
' Add emails to the bundle from the zip.
if (mailBundle.AddFromZip(zip)) then
For i = 0 To mailBundle.messageCount - 1
Set email = mailBundle.GetEmail(i)
' Clear the CC, Bcc, and To recipients
email.ClearTo
email.ClearBcc
email.ClearCC
' All e-mails are being forwarded to john.doe@something.com
email.AddTo "John Doe","john.doe@something.com"
Response.write "<hr><br><b>Message Number " & i & "</b><br>"
Response.write "<b>From:</b> " & _
Server.HTMLEncode(email.From) & "<br>"
Response.write "<b>Subject:</b> " & _
Server.HTMLEncode(email.Subject) & "<br>"
Response.write "Sending to "& _
Server.HTMLEncode(email.GetTo(0)) & "<br>"
' Send the email
if mailman.SendEmail(email) then
Response.write "Message sent successfully!<br><br>"
else
Response.write "ERROR: Message not sent!<br><br>"
end if
Set email = Nothing
Next
else
Response.write "Failed to get emails from Zip"
end if
Set mailBundle = Nothing
Set zip = Nothing
Set mailman = Nothing
%>
<BR>DONE.<BR>
</BODY>
</HTML>
|
|
Privacy
Statement. Copyright 2000-2008 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.
|
|