code_junkie

Processing incoming email

Nov 13th, 2011
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. //create a new IMAP4 object, connect
  2. //to a IMAP4 server and login
  3. IMAP4 imap = new IMAP4();
  4. imap.Connect("mail.yourdomain.com");
  5. imap.Login("mailbox", "password");
  6.  
  7. //select the inbox and download the envelopes
  8. imap.SelectMailbox("Inbox");
  9. EnvelopeCollection imapEnvelopes;
  10. imapEnvelopes = imap.GetEnvelopes();
  11.  
  12. //loop through each message
  13. //and output the subject
  14. foreach (Envelope imapEnvelope in imapEnvelopes)
  15. {
  16. //write the subject out to the console
  17. Console.WriteLine(imapEnvelope.Subject);
  18. }
  19.  
  20. //close resources
  21. imap.Logout();
Add Comment
Please, Sign In to add comment