Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
|
|
Fetch Single Email by UID or Sequence Number
Assuming the UID is known, download a single email by UID from an IMAP mail server. <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> <% set imap = Server.CreateObject("Chilkat.Imap") ' Anything unlocks the component and begins a fully-functional 30-day trial. success = imap.UnlockComponent("Anything for 30-day trial") If (success <> 1) Then Response.Write Server.HtmlEncode(imap.LastErrorText) & "<br>" End If ' Connect to an IMAP server. success = imap.Connect("mail.chilkatsoft.com") If (success <> 1) Then Response.Write Server.HtmlEncode(imap.LastErrorText) & "<br>" End If ' Login success = imap.Login("***","***") If (success <> 1) Then Response.Write Server.HtmlEncode(imap.LastErrorText) & "<br>" End If ' Select an IMAP mailbox success = imap.SelectMailbox("Inbox") If (success <> 1) Then Response.Write Server.HtmlEncode(imap.LastErrorText) & "<br>" End If uid = 2014 isUid = 1 Set email = imap.FetchSingle(uid,isUid) If (Not (email Is Nothing )) Then ' Display the From and Subject Response.Write Server.HtmlEncode(email.FromAddress) & "<br>" Response.Write Server.HtmlEncode(email.Subject) & "<br>" ' Display the Body property, which is the default body. ' If an email has an HTML body, the Body property contains ' the HTML source. Otherwise it contains the plain-text ' body. Response.Write Server.HtmlEncode("---- EMAIL BODY ----") & "<br>" Response.Write Server.HtmlEncode(email.Body) & "<br>" Response.Write Server.HtmlEncode("--------------------") & "<br>" ' Display the recipients: For j = 0 To email.NumTo - 1 Response.Write Server.HtmlEncode(email.GetToName(j) _ & ", " & email.GetToAddr(j)) & "<br>" Next For j = 0 To email.NumCC - 1 Response.Write Server.HtmlEncode(email.GetCcName(j) _ & ", " & email.GetCcAddr(j)) & "<br>" Next ' Show the total size of the email, including body and attachments: Response.Write Server.HtmlEncode(email.Size) & "<br>" ' When a full email is downloaded, we would use the ' email.NumAttachments property in conjunction with the ' email.GetMailAttach* methods. ' However, when an email object contains only the header, ' we need to access the attachment info differently: numAttach = imap.GetMailNumAttach(email) Response.Write Server.HtmlEncode(numAttach) & "<br>" For j = 0 To numAttach - 1 Response.Write Server.HtmlEncode(imap.GetMailAttachFilename(email,j)) & "<br>" attachSize = imap.GetMailAttachSize(email,j) Response.Write Server.HtmlEncode(" size = " _ & attachSize & " bytes") & "<br>" Next Response.Write Server.HtmlEncode("--") & "<br>" End If ' Disconnect from the IMAP server. imap.Disconnect %> </body> </html> |
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.