Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
Read IMAP Email Demonstrates how to read email on an IMAP server.
' This example downloads and prints the From/Subject of all email from the
' INBOX of an IMAP user account.
' Note: Programming in VBScript is almost identical to programming
' in Visual Basic 6.0. You may wish to review the additional VB6 IMAP example
' programs at http://www.example-code.com/vb/imap.asp
set imap = CreateObject("ChilkatImap.ChilkatImap")
success = imap.UnlockComponent("Anything for 30-day trial")
if success = 0 then
MsgBox "Failed to unlock component"
' ...
end if
' Connect to an IMAP server.
success = imap.Connect("mail.chilkatsoft.com")
if success = 0 then
' Failed
MsgBox imap.LastErrorText
' ...
end if
' Login
success = imap.Login("myLogin", "myPassword")
if success = 0 then
' Failed
MsgBox imap.LastErrorText
' ...
end if
success = imap.SelectMailbox("INBOX")
if success = 0 then
' Failed
MsgBox imap.LastErrorText
' ...
end if
' Get the complete set of UIDs for all the emails in the mailbox.
useUids = 1
set msgSet = imap.Search("ALL",1)
if msgSet is Nothing then
' Failed
MsgBox imap.LastErrorText
' ...
end if
' Fetch all the mail into a bundle object.
' To fetch entire emails, including attachments, call FetchBundle.
' To fetch headers only, call FetchHeaders.
'Set bundle = imap.FetchBundle(msgSet)
Set bundle = imap.FetchHeaders(msgSet)
if bundle is Nothing then
' Failed
MsgBox imap.LastErrorText
' ...
end if
' Loop over the bundle and display the From and Subject.
s = ""
For i = 0 To bundle.MessageCount - 1
Set email = bundle.GetEmail(i)
s = s & email.From & ": " & email.Subject & vbCrLf
Next
MsgBox s
' Disconnect from the IMAP server.
' This example leaves the email on the IMAP server.
imap.Disconnect
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2003-2007 Chilkat Software, Inc. All Rights Reserved.