VBScript
VBScript
Unsubscribe from an IMAP Mailbox
See more IMAP Examples
Demonstrates the Chilkat Imap.Unsubscribe method, which removes the subscription to a mailbox. The mailbox itself and its messages are not deleted. This example unsubscribes from a mailbox.
Background: Unsubscribing simply drops a mailbox from the account's subscription list, so clients that show only subscribed folders will stop displaying it — the folder and everything in it remain on the server untouched. This is the counterpart to
Subscribe, and is how you declutter a mailbox listing without deleting anything (deleting a folder is DeleteMailbox).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.Unsubscribe method, which removes the subscription to a mailbox.
' The mailbox itself and its messages are not deleted.
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
' Remove the subscription to a mailbox (the mailbox is not deleted).
success = imap.Unsubscribe("Archive2026")
If (success = 0) Then
outFile.WriteLine(imap.LastErrorText)
WScript.Quit
End If
outFile.WriteLine("Unsubscribed from the mailbox.")
success = imap.Disconnect()
If (success = 0) Then
outFile.WriteLine(imap.LastErrorText)
WScript.Quit
End If
outFile.Close