Created
March 12, 2021 01:41
-
-
Save aspose-com-gists/511425122d8f8dce06ef076bb0308463 to your computer and use it in GitHub Desktop.
Connect to IMAP Server in C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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