VBScript
VBScript
Subscribe to an IMAP Mailbox
See more IMAP Examples
Demonstrates the Chilkat Imap.Subscribe method, which subscribes the authenticated IMAP account to a mailbox. Subscription controls which mailboxes are returned by subscribed-mailbox listings. This example subscribes to a mailbox.
Background: An account can have many mailboxes, but a user often cares about only some of them. IMAP's subscription list is that curated set: mail clients typically show subscribed folders by default and hide the rest. Subscribing does not create or change a mailbox — it only adds it to the "show me this one" list (retrieved with a subscribed-only listing).
Unsubscribe removes it from that list.Chilkat VBScript Downloads
Dim fso, outFile
Set fso = CreateObject("Scripting.FileSystemObject")
'Create a Unicode (utf-16) output text file.
Set outFile = fso.CreateTextFile("output.txt", True, True)
success = 0
' Demonstrates the Imap.Subscribe method, which subscribes the authenticated IMAP account to
' a mailbox. Subscription controls which mailboxes are returned by subscribed-mailbox
' listings.
set imap = CreateObject("Chilkat.Imap")
imap.Ssl = 1
imap.Port = 993
success = imap.Connect("imap.example.com")
If (success = 0) Then
outFile.WriteLine(imap.LastErrorText)
WScript.Quit
End If
success = imap.Login("user@example.com","myPassword")
If (success = 0) Then
outFile.WriteLine(imap.LastErrorText)
WScript.Quit
End If
' Subscribe to a mailbox.
success = imap.Subscribe("Archive2026")
If (success = 0) Then
outFile.WriteLine(imap.LastErrorText)
WScript.Quit
End If
outFile.WriteLine("Subscribed to the mailbox.")
success = imap.Disconnect()
If (success = 0) Then
outFile.WriteLine(imap.LastErrorText)
WScript.Quit
End If
outFile.Close