|

DOWNLOAD
Reference
ASP Examples
WebMail Example
Access
the data in an Email attachment (in multipart MIME messages)
This example shows how to access the data in an
Email attachment.
<%@ LANGUAGE="VBSCRIPT" %>
<HTML>
<HEAD>
<TITLE>Chilkat WebMail Example: Access the data in an e-mail attachment</TITLE>
</HEAD>
<BODY>
Reading email....<br><br>
<%
' 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 to get mail (POP3 server), and the login/password
mailman.MailHost = "mail.somedomain.com"
mailman.PopUsername = "my_username"
mailman.PopPassword = "my_password"
' Copy the mail without removing it from the server.
' When reading email, the mailman always returns a MailBundle
Set mailBundle = mailman.CopyMail
If Not (mailBundle Is Nothing) Then
' Loop over the email messages in the bundle
For i = 0 To mailBundle.messageCount - 1
Set email = mailBundle.GetEmail(i)
Response.write "<hr><br><b>Message Number:</b>" & i & "<br>"
Response.write "<b>From:</b> " & Server.HTMLEncode(email.From) & "<br>"
Response.write "<b>Subject:</b> " & Server.HTMLEncode(email.Subject) & "<br>"
Response.write "<b>Number of Attachments:</b>" & email.NumAttachments & "<br>"
if email.NumAttachments > 0 then
Response.write "<blockquote>"
For j = 0 to email.NumAttachments-1
' Display the attachment filename.
filename = email.GetAttachmentFilename(j)
Response.write "<b>Filename: </b> " _
& Server.HTMLEncode(filename) & "<br>"
if InStr(LCase(filename),".txt") then
Response.write "<blockquote><pre>"
Response.write Server.HTMLEncode(email.GetAttachmentString(j))
Response.write "</pre></blockquote><br>"
end if
Next
Response.write "</blockquote><br>"
end if
Set email = Nothing
Next
End If
%>
<br>(View page source to see the log)
<XML ID="XMLID">
<%
Response.write mailman.GetInstanceLog()
%>
</XML>
<%
Set mailBundle = Nothing
' Standard ASP cleanup of objects
Set mailman = Nothing
%>
<BR>DONE.<BR>
</BODY>
</HTML>
|
* Email messages with attachments are multipart MIME messages,
and can be multipart/alternative, multipart/related, or multipart/mixed.
Chilkat Web Mail handles the complexities and composition of creating
the correct multipart MIME message, so you don't have to.
|
Privacy
Statement. Copyright 2000-2012 Chilkat
Software, Inc. All rights reserved.
(Regarding the usage of the Android logo) Portions of this page are reproduced from work created and shared by Google
and used according to terms described in the Creative Commons
3.0 Attribution License.
Send feedback to support@chilkatsoft.com
Software components and libraries for Linux, MAC OS X, IOS (IPhone), Android™, Solaris, RHEL/CentOS Microsoft Windows 7, Vista, XP, 2000, 2003 Server, 2008 Server, and Windows 95/98/NT4.
|
|