Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Create a folder named "inbox" under current directory
- // to save the email retrieved.
- string curpath = Directory.GetCurrentDirectory();
- string mailbox = String.Format("{0}\\inbox", curpath);
- // If the folder is not existed, create it.
- if (!Directory.Exists(mailbox))
- {
- Directory.CreateDirectory(mailbox);
- }
- // Gmail IMAP4 server is "imap.gmail.com"
- MailServer oServer = new MailServer("imap.gmail.com", "awefiweaf@gmail.com", "unfdb", ServerProtocol.Imap4);
- MailClient oClient = new MailClient("TryIt");
- // Set SSL connection,
- oServer.SSLConnection = true;
- // Set 993 IMAP4 port
- oServer.Port = 993;
- oClient.Connect(oServer);
- MailInfo[] infos = oClient.GetMailInfos();
- for (int i = infos.Length - 1; i >= infos.Length - 15; i-- )
- {
- if (i < 0)
- {
- continue;
- }
- MailInfo info = infos[i];
- Mail oMail = oClient.GetMail(info);
- if (oMail.To.Contains("thekebab") == false)
- {
- // continue;
- }
- Console.WriteLine("From: {0}", oMail.From.ToString());
- Console.WriteLine("To: {0}", oMail.To[0]);
- Console.WriteLine("Subject: {0}\r\n", oMail.Subject);
- if (oMail.Subject.StartsWith("Your Origin Security Code"))
- {
- Console.WriteLine("^^^^^^^^^^");
- }
- }
- // Quit and pure emails marked as deleted from Gmail IMAP4 server.
- oClient.Quit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement