Disconnects from the IMAP server and returns exit message from the server.
public string Disconnect()
Public Function Disconnect As String
public:
String Disconnect();
Return Value
The exit message returned by the server.
Connect to an IMAP server and list existing mailboxes.
using System;
using System.Text;
using ComponentPro.Net.Mail;
...
// Create a new instance of the Imap class.
Imap client = new Imap();
// Connect to the server.
client.Connect("myserver");
// Or you can specify the IMAP port with
// client.Connect("myserver", 143);
// Login to the server.
client.Authenticate("user", "password");
StringBuilder sb = new StringBuilder();
FolderCollection list = client.ListFolders();
for (int i = 0; i < list.Count; i++)
{
sb.AppendFormat("{0} - {1}\r\n", i + 1, list[i].Name);
}
Console.WriteLine(sb.ToString());
// Close the connection.
client.Disconnect();
Imports System.Text
Imports ComponentPro.Net.Mail
...
' Create a new instance of the Imap class.
Dim client As New Imap()
' Connect to the server.
client.Connect("myserver")
' Or you can specify the IMAP port with
' client.Connect("myserver", 143);
' Login to the server.
client.Authenticate("user", "password")
Dim sb As New StringBuilder()
Dim list As FolderCollection = client.ListFolders()
For i As Integer = 0 To list.Count - 1
sb.AppendFormat("{0} - {1}" & vbCrLf, i + 1, list(i).Name)
Next i
Console.WriteLine(sb.ToString())
' Close the connection.
client.Disconnect()
Connect to an IMAP server using Explicit security mode.
using System;
using System.Text;
using ComponentPro.Net;
using ComponentPro.Net.Mail;
...
// Create a new instance of the Imap class.
Imap client = new Imap();
// Connect to the server.
client.Connect("myserver", 143, SslSecurityMode.Explicit);
// Login to the server.
client.Authenticate("user", "password");
StringBuilder sb = new StringBuilder();
FolderCollection list = client.ListFolders();
for (int i = 0; i < list.Count; i++)
{
sb.AppendFormat("{0} - {1}\r\n", i + 1, list[i].Name);
}
Console.WriteLine(sb.ToString());
// Close the connection.
client.Disconnect();
Imports System.Text
Imports ComponentPro.Net
Imports ComponentPro.Net.Mail
...
' Create a new instance of the Imap class.
Dim client As New Imap()
' Connect to the server.
client.Connect("myserver", 143, SslSecurityMode.Explicit)
' Login to the server.
client.Authenticate("user", "password")
Dim sb As New StringBuilder()
Dim list As FolderCollection = client.ListFolders()
For i As Integer = 0 To list.Count - 1
sb.AppendFormat("{0} - {1}" & vbCrLf, i + 1, list(i).Name)
Next i
Console.WriteLine(sb.ToString())
' Close the connection.
client.Disconnect()