By using the AdvancedIntellect.Ssl.dll, you can enable the aspNetIMAP.dll to communicate to your IMAP servers over SSL. Download the AdvancedIntellect.Ssl.dll from www.advancedintellect.com/download.aspx . Once you have imported it into your project, you can set a reference to the AdvancedIntellect.Ssl.dll.
To convert your code to support Ssl will only take a few
changes. You will simply need to create the Ssl socket, load it into the
IMAP object, and possibly change the IMAP port to a SSL port.
Below you will find a code example for enabling SSL. For more information, be sure to check out the AdvancedIntellect.Ssl.chm help file, downloaded with the AdvancedIntellect.Ssl.dll.
The highlighted code in yellow is the only additional code needed to enable SSL support.
[C#]
IMAP4 imap = new IMAP4( "127.0.0.1" ); imap.Logger = new IMAPLog(); //create and load the ssl socket AdvancedIntellect.Ssl.SslSocket ssl = new AdvancedIntellect.Ssl.SslSocket(); imap.LoadSslSocket( ssl ); imap.Port = 993; //IMAP Ssl port //if we have write permissions to the filesystem, we can write out a physical log file imap.Logger.Path = "c:\\imap.log"; //if we don't have write permissions to a file, we can always keep an in-memory log imap.Logger.InMemory = true; imap.Username = "dave@blah.com"; imap.Password = "test"; imap.Login(); //list all of the folders MailFolderCollection mfc = imap.FolderList(); Console.WriteLine( mfc.ToString() ); //write out the log Console.WriteLine( imap.Logger.ToString() ); imap.Disconnect(); Console.WriteLine( "Done" ); Console.ReadLine();
[VB.NET]
Dim imap As New IMAP4("127.0.0.1") imap.Logger = New IMAPLog() 'create and load the ssl socket Dim ssl As New AdvancedIntellect.Ssl.SslSocket() imap.LoadSslSocket(ssl) imap.Port = 993 'IMAP Ssl port 'if we have write permissions to the filesystem, we can write out a physical log file imap.Logger.Path = "c:\imap.log" 'if we don't have write permissions to a file, we can always keep an in-memory log imap.Logger.InMemory = True imap.Username = "dave@blah.com" imap.Password = "test" imap.Login() 'list all of the folders Dim mfc As MailFolderCollection = imap.FolderList() Console.WriteLine(mfc.ToString()) 'write out the log Console.WriteLine(imap.Logger.ToString()) imap.Disconnect() Console.WriteLine("Done") Console.ReadLine()