Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Code to access IMAP mail server and to read, delete and move emails between folders
- private void Connect_Click_1(object sender, EventArgs e)
- {
- string host = "mail.abc.com";
- string username = "autoresp@abc.com";
- string password = "xxxxxxxx";
- TcpIMAP imap = new TcpIMAP();
- imap.Connect(host, 143);
- imap.AuthenticateUser(username, password);
- Console.WriteLine("Total Messages " + imap.MailCount());
- Console.WriteLine("Total Unread Messages " + imap.MailUnreadCount());
- // You need to select the inbox in order to view the your messages
- imap.SelectInbox();
- object retmailID = imap.GetMessage(1);
- object retmail = imap.GetMessage(1);
- string inforet = retmail.ToString();
- Message.Clear();
- Message.Text += inforet;
- DiscectEmail(inforet);
- // Select an IMAP mailbox
- string success;
- string sMessageUID;
- string destfolder = "";
- ImapResponseEnum eImapResponse = ImapResponseEnum.IMAP_SUCCESS_RESPONSE;
- string sCommandSuffix = "";
- imap.Disconnect();
- //Console.ReadKey();
- }
- public void SelectInbox()
- {
- _imapSw.WriteLine("$ SELECT INBOX.Autoresp.Inbox");
- _imapSw.Flush();
- Response();
- }
Add Comment
Please, Sign In to add comment