VBScript Examples

ChilkatHOMEAndroid™ASPVisual BasicVB.NETC#iOS (IPhone)Objective-CC++CMFCDelphiFoxProJavaPerl
PHP ExtensionPHP ActiveXPythonPowerShellRubySQL ServerVBScript

VBScript Examples

Bounced Mail
Bz2
Character Encoding
Digital Certificates
CSV
Digital Signatures
Email
FTP
HTML Conversion
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
PFX
RSA
S/MIME
SFTP
SMTP
Socket
Spider
SSH
SSH Key
SSH Tunnel
String
Tar
Upload
XML
XMP
Zip Compression
Self-Extractor

More Examples...
Amazon S3
Email Object
DKIM / DomainKey
NTLM
FileAccess
Byte Array
RSS
Atom
Service
PPMD
Deflate
DH Key Exchange
DSA
Bzip2
LZW

 

 

 

 

 

 

 

Fetch Single Email by UID or Sequence Number

Download 32-bit Chilkat IMAP ActiveX (.msi)

Download All 32-bit Chilkat ActiveX Components (.zip)

Download All 64-bit Chilkat ActiveX Components (.zip)

Assuming the UID is known, download a single email by UID from an IMAP mail server.

Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set outFile = fso.CreateTextFile("output.txt", True)

set imap = 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
    MsgBox imap.LastErrorText
    WScript.Quit
End If

'  Connect to an IMAP server.
success = imap.Connect("mail.chilkatsoft.com")
If (success <> 1) Then
    MsgBox imap.LastErrorText
    WScript.Quit
End If

'  Login
success = imap.Login("***","***")
If (success <> 1) Then
    MsgBox imap.LastErrorText
    WScript.Quit
End If

'  Select an IMAP mailbox
success = imap.SelectMailbox("Inbox")
If (success <> 1) Then
    MsgBox imap.LastErrorText
    WScript.Quit
End If

uid = 2014
isUid = 1

Set email = imap.FetchSingle(uid,isUid)
If (Not (email Is Nothing )) Then

    '  Display the From and Subject
    outFile.WriteLine(email.FromAddress)
    outFile.WriteLine(email.Subject)

    '  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.
    outFile.WriteLine("---- EMAIL BODY ----")
    outFile.WriteLine(email.Body)
    outFile.WriteLine("--------------------")

    '  Display the recipients:

    For j = 0 To email.NumTo - 1
        outFile.WriteLine(email.GetToName(j) _
             & ", " & email.GetToAddr(j))
    Next
    For j = 0 To email.NumCC - 1
        outFile.WriteLine(email.GetCcName(j) _
             & ", " & email.GetCcAddr(j))
    Next

    '  Show the total size of the email, including body and attachments:
    outFile.WriteLine(email.Size)

    '  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)
    outFile.WriteLine(numAttach)

    For j = 0 To numAttach - 1
        outFile.WriteLine(imap.GetMailAttachFilename(email,j))
        attachSize = imap.GetMailAttachSize(email,j)
        outFile.WriteLine("    size = " & attachSize _
             & " bytes")
    Next

    outFile.WriteLine("--")

End If

'  Disconnect from the IMAP server.
imap.Disconnect 
outFile.Close

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.

Mail Component · XML Parser