Here is a WinBatch dotNet example that uses the MailSystem.NET (http://mailsystem.codeplex.com/) component to list mailboxes on an IMAP server:
;***************************************************************************
;** List IMAP Mailboxes
;**
;** Purpose: Uses MailSystem.NET (http://mailsystem.codeplex.com/) component to List IMAP Mailboxes
;** Inputs: imapserver, username, password and assemblydir
;** Outputs: Mailboxes returned from Getmailbox
;** Reference:
;** REQUIRES MailSystem.NET (http://mailsystem.codeplex.com/)
;** WinBatch 2013A or newer
;**
;** Developer: Deana Falk 2013.08.22
;
;Use SN.EXE (Microsoft (R) .NET Framework Strong Name Utility Version 4.0.30319.17929) to get Public key token
;C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools>sn -T "C:\WWW\__SCRIPT LIBRARY\DotNet\Third Party\MailSystem\ActiveUp.MailSystem_May2013_Binaries\Release\ActiveUp.Net.Imap4.dll"
;Public key token is 9d424b1770e92b68
;
;***************************************************************************
If Version( )< '2013A'
Pause('Notice', 'Need 2013A or Newer Version of WinBatch')
Exit
EndIf
;!!! MODIFY TO FIT YOUR NEEDS !!!
imapserver = 'imap.gmail.com'
user = 'johndoe@gmail.com'
pswd = 'supersecret'
assemblydir = 'C:\WWW\__SCRIPT LIBRARY\DotNet\Third Party\MailSystem\ActiveUp.MailSystem_May2013_Binaries\Release\'
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Load assemblies into the WinBatch process.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;AppBase: You DO NOT use the names of files containing assemblies (i.e. ActiveUp.Net.Imap4.dll) with the 'AppBase' option.
; You Do specify the full (not partial) path to the location of the assemblies you are going to use in your script that are not in the GAC.
; Logically this means that all non GAC assemblies need to be placed in the same directory for a given script.
ObjectClrOption('appbase',assemblydir)
ObjectClrOption ('use','ActiveUp.Net.Imap4, Version=5.0.3454.364, Culture=neutral, PublicKeyToken=9d424b1770e92b68')
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
; Create a class implemented by a managed assembly.
;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
imap = ObjectClrNew( 'ActiveUp.Net.Mail.Imap4Client')
imap.ConnectSsl(imapserver, 993);
imap.Login(user,pswd)
;Return all children mailboxes of "inbox".
MailboxCollection = imap.GetMailboxes("inbox","*")
list = ''
cnt = MailboxCollection.Count
If cnt >0
For x = 0 to cnt-1
data = MailboxCollection.Item(x).Name
if list == "" then list = data
else list = list:@TAB:data
Next
Else
list = 'NO MAILBOXES FOUND'
Endif
AskItemList('Mailboxes', list, @TAB, @UNSORTED, @SINGLE )
imap.Disconnect();
Exit