Guest User

Untitled

a guest
Aug 22nd, 2018
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. Code to access IMAP mail server and to read, delete and move emails between folders
  2. private void Connect_Click_1(object sender, EventArgs e)
  3. {
  4. string host = "mail.abc.com";
  5. string username = "autoresp@abc.com";
  6. string password = "xxxxxxxx";
  7.  
  8. TcpIMAP imap = new TcpIMAP();
  9. imap.Connect(host, 143);
  10. imap.AuthenticateUser(username, password);
  11.  
  12. Console.WriteLine("Total Messages " + imap.MailCount());
  13. Console.WriteLine("Total Unread Messages " + imap.MailUnreadCount());
  14.  
  15. // You need to select the inbox in order to view the your messages
  16.  
  17. imap.SelectInbox();
  18.  
  19.  
  20. object retmailID = imap.GetMessage(1);
  21. object retmail = imap.GetMessage(1);
  22. string inforet = retmail.ToString();
  23.  
  24. Message.Clear();
  25. Message.Text += inforet;
  26. DiscectEmail(inforet);
  27.  
  28.  
  29.  
  30. // Select an IMAP mailbox
  31. string success;
  32.  
  33. string sMessageUID;
  34. string destfolder = "";
  35.  
  36. ImapResponseEnum eImapResponse = ImapResponseEnum.IMAP_SUCCESS_RESPONSE;
  37. string sCommandSuffix = "";
  38.  
  39.  
  40. imap.Disconnect();
  41.  
  42. //Console.ReadKey();
  43.  
  44. }
  45.  
  46. public void SelectInbox()
  47. {
  48. _imapSw.WriteLine("$ SELECT INBOX.Autoresp.Inbox");
  49. _imapSw.Flush();
  50. Response();
  51. }
Add Comment
Please, Sign In to add comment