Advertisement
Guest User

Untitled

a guest
Dec 20th, 2014
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. // Create a folder named "inbox" under current directory
  2. // to save the email retrieved.
  3. string curpath = Directory.GetCurrentDirectory();
  4. string mailbox = String.Format("{0}\\inbox", curpath);
  5.  
  6. // If the folder is not existed, create it.
  7. if (!Directory.Exists(mailbox))
  8. {
  9. Directory.CreateDirectory(mailbox);
  10. }
  11.  
  12. // Gmail IMAP4 server is "imap.gmail.com"
  13. MailServer oServer = new MailServer("imap.gmail.com", "awefiweaf@gmail.com", "unfdb", ServerProtocol.Imap4);
  14. MailClient oClient = new MailClient("TryIt");
  15.  
  16. // Set SSL connection,
  17. oServer.SSLConnection = true;
  18.  
  19. // Set 993 IMAP4 port
  20. oServer.Port = 993;
  21.  
  22. oClient.Connect(oServer);
  23. MailInfo[] infos = oClient.GetMailInfos();
  24.  
  25. for (int i = infos.Length - 1; i >= infos.Length - 15; i-- )
  26. {
  27. if (i < 0)
  28. {
  29. continue;
  30. }
  31. MailInfo info = infos[i];
  32.  
  33. Mail oMail = oClient.GetMail(info);
  34. if (oMail.To.Contains("thekebab") == false)
  35. {
  36. // continue;
  37. }
  38. Console.WriteLine("From: {0}", oMail.From.ToString());
  39. Console.WriteLine("To: {0}", oMail.To[0]);
  40.  
  41. Console.WriteLine("Subject: {0}\r\n", oMail.Subject);
  42.  
  43. if (oMail.Subject.StartsWith("Your Origin Security Code"))
  44. {
  45. Console.WriteLine("^^^^^^^^^^");
  46. }
  47. }
  48.  
  49. // Quit and pure emails marked as deleted from Gmail IMAP4 server.
  50. oClient.Quit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement