Skip to content

Instantly share code, notes, and snippets.

@aspose-com-gists
Created March 12, 2021 01:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-com-gists/511425122d8f8dce06ef076bb0308463 to your computer and use it in GitHub Desktop.
Save aspose-com-gists/511425122d8f8dce06ef076bb0308463 to your computer and use it in GitHub Desktop.
Connect to IMAP Server in C#
// Configure HTTP proxy
HttpProxy proxy = new HttpProxy("18.222.124.59", 8080);
// Create and configure ImapClient and set HTTP proxy
using (ImapClient client = new ImapClient("imap.domain.com", "username", "password"))
{
// Set proxy
client.Proxy = proxy;
// Select folder
client.SelectFolder("Inbox");
}
// Connect and log in to IMAP and set SecurityOptions
ImapClient client = new ImapClient("imap.domain.com", "username", "password");
client.SecurityOptions = SecurityOptions.Auto;
// Configure SOCKS proxy
string proxyAddress = "192.168.203.142"; // proxy address
int proxyPort = 1080; // proxy port
SocksProxy proxy = new SocksProxy(proxyAddress, proxyPort, SocksVersion.SocksV5);
// Set the proxy for IMAP
client.Proxy = proxy;
// Select folder
client.SelectFolder("Inbox");
// Create an instance of the ImapClient class
ImapClient client = new ImapClient("imap.domain.com", 993, "user@domain.com", "pwd");
// Set the security mode to implicit
client.SecurityOptions = SecurityOptions.SSLImplicit;
// Select folder
client.SelectFolder("Inbox");
// Connect to IMAP server using host, user and password
ImapClient client = new ImapClient("localhost", "user", "password");
// Select folder
client.SelectFolder("Inbox");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment