public void ProcessValidEmail(Chilkat.Email email) { //Raise event var emailEventArgs = new MyEmailEventArgs(); emailEventArgs.From = EmailUtility.CleanEmailAddress(email.From); emailEventArgs.Subject = email.Subject; emailEventArgs.Uidl = email.Uidl; emailEventArgs.Content = email.Body; OnFoundEmail(emailEventArgs); //int numAttached; //bool success; //numAttached = email.NumAttachments; //if (numAttached > 0) //{ // success = email.SaveAllAttachments(email.Uidl + "myAttachments"); // if (success != true) // { // Console.WriteLine(email.LastErrorText); // } //} }
public bool SendEmail(string subject, string body, string emailFrom, string emailTo) { // The mailman object is used for receiving (POP3) // and sending (SMTP) email. Chilkat.MailMan mailman = new Chilkat.MailMan(); // Note: This example requires licenses to both "Chilkat Email" and "Chilkat MHT". // Any string argument automatically begins the 30-day trial. bool success; success = mailman.UnlockComponent(ChilkatEmailUnlock); if (success != true) return false; Chilkat.Email email = new Chilkat.Email(); email.Subject = subject; email.Body = body; email.AddTo(emailTo, emailTo); email.From = emailFrom; mailman.SmtpHost = strSmtpHost; mailman.SmtpUsername = strSmtpUser; mailman.SmtpPassword = strSmtpPass; mailman.SmtpPort = iSmtpPort; mailman.StartTLS = startTLS; if (Charset.Length != 0) email.Charset = Charset; success = mailman.SendEmail(email); if (success != true) return false; success = mailman.CloseSmtpConnection(); return true; }
public void sendAttachedFile(string filename, byte[] data, bool bTilPBS) { string local_filename = filename.Replace('.', '_') + ".txt"; Chilkat.MailMan mailman = new Chilkat.MailMan(); bool success; success = mailman.UnlockComponent("HAFSJOMAILQ_9QYSMgP0oR1h"); if (success != true) { throw new Exception(mailman.LastErrorText); } // Use the GMail SMTP server mailman.SmtpHost = Program.Smtphost; mailman.SmtpPort = int.Parse(Program.Smtpport); mailman.SmtpSsl = bool.Parse(Program.Smtpssl); // Set the SMTP login/password. mailman.SmtpUsername = Program.Smtpuser; mailman.SmtpPassword = Program.Smtppasswd; // Create a new email object Chilkat.Email email = new Chilkat.Email(); if (bTilPBS) { #if (DEBUG) email.Subject = "Test Til PBS: " + local_filename; email.Body = "Test Til PBS: " + local_filename; #else email.Subject = "Til PBS: " + local_filename; email.Body = "Til PBS: " + local_filename; #endif } else { #if (DEBUG) email.Subject = "Test Fra PBS: " + local_filename; email.Body = "Test Fra PBS: " + local_filename; #else email.Subject = "Fra PBS: " + local_filename; email.Body = "Fra PBS: " + local_filename; #endif } email.AddTo(Program.MailToName, Program.MailToAddr); email.From = Program.MailFrom; email.ReplyTo = Program.MailReply; email.AddDataAttachment2(local_filename, data, "text/plain"); email.UnzipAttachments(); success = mailman.SendEmail(email); if (success != true) { throw new Exception(email.LastErrorText); } }
public void Scan() { Chilkat.StringArray saUidls = null; // Get the complete list of UIDLs saUidls = mailMan.GetUidls(); if (saUidls == null) { return; } // Get the 10 most recent UIDLs // The 1st email is the oldest, the last email is the newest // (usually) int i; int n; int startIdx; int bundleSize = 3; n = saUidls.Count; startIdx = n > bundleSize ? n - bundleSize : 0; Chilkat.StringArray saUidls2 = new Chilkat.StringArray(); for (i = startIdx; i <= n - 1; i++) { saUidls2.Append(saUidls.GetString(i)); } // Download in full the 10 most recent emails: Chilkat.EmailBundle bundle = null; bundle = mailMan.FetchMultiple(saUidls2); if (bundle == null) { Console.WriteLine(mailMan.LastErrorText); return; } Chilkat.Email email = null; for (i = 0; i <= bundle.MessageCount - 1; i++) { email = bundle.GetEmail(i); Console.WriteLine(email.From); Console.WriteLine(email.Subject); Console.WriteLine("----"); if (email == null) { Console.WriteLine(mailMan.LastErrorText); return; } if (ValidateCommand(email)) { ProcessValidEmail(email); } else { ProcessInvalidEmail(email); } } }
public EmailMessage(string uid, Chilkat.Email msg) { _toAddr = msg.GetTo(0); _fromAddr = msg.From.ToString(); _bcc = ""; for (int i = 0; i <= msg.NumCC - 1; i++) { _bcc += msg.GetCC(i) + " "; } _subject = msg.Subject; _receiveDate = msg.EmailDate; _filename = null; _message = msg.GetPlainTextBody(); _UID = msg.Uidl; _emailMessage = msg; }
public string Connect(string yahooEmail, string yahooPassword) { string decodedActivationLink = string.Empty; iMap.UnlockComponent("THEBACIMAPMAILQ_OtWKOHoF1R0Q"); iMap.Connect("imap.n.mail.yahoo.com"); //iMap.Login("*****@*****.**", "rga77qViNIV"); iMap.Login(yahooEmail, yahooPassword); iMap.SelectMailbox("Inbox"); // Get a message set containing all the message IDs // in the selected mailbox. Chilkat.MessageSet msgSet; msgSet = iMap.Search("ALL", true); // Fetch all the mail into a bundle object. Chilkat.Email email = new Chilkat.Email(); //bundle = iMap.FetchBundle(msgSet); for (int i = msgSet.Count - 1; i > 0; i--) { try { email = iMap.FetchSingle(msgSet.GetId(i), true); if (email.Subject.Contains("Action Required: Confirm Your Facebook Account")) { int startIndex = email.Body.IndexOf("http://www.facebook.com/confirmemail.php?e="); int endIndex = email.Body.IndexOf(">", startIndex) - 1; string activationLink = email.Body.Substring(startIndex, endIndex - startIndex).Replace("\r\n", ""); activationLink = activationLink.Replace("3D", "").Replace("hotmai=l", "hotmail").Replace("%40", "@"); decodedActivationLink = Uri.UnescapeDataString(activationLink); } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } } return decodedActivationLink; }
public void Process(MyEmailEventArgs e) { Console.WriteLine("Forwarding message {0}!!!", e.Subject); Chilkat.Email mail = mailMan.FetchEmail(e.Uidl); if (mail == null) { Console.WriteLine("Cannot get the remail {0}", e.Uidl); return; } Chilkat.Email forwardMail = mail.CreateForward(); forwardMail.From = "*****@*****.**"; forwardMail.AddTo("Thao Vo", "*****@*****.**"); bool success = mailMan.SendEmail(forwardMail); if (success == false) { Console.WriteLine(mailMan.LastErrorText); } PostProcessCommand(e); }
public void sendAttachedFile(string MailBody) { Chilkat.MailMan mailman = new Chilkat.MailMan(); bool success; success = mailman.UnlockComponent("HAFSJOMAILQ_9QYSMgP0oR1h"); if (success != true) { throw new Exception(mailman.LastErrorText); } // Use the GMail SMTP server mailman.SmtpHost = Program.Smtphost; mailman.SmtpPort = int.Parse(Program.Smtpport); mailman.SmtpSsl = bool.Parse(Program.Smtpssl); // Set the SMTP login/password. mailman.SmtpUsername = Program.Smtpuser; mailman.SmtpPassword = Program.Smtppasswd; // Create a new email object Chilkat.Email email = new Chilkat.Email(); #if (DEBUG) email.Subject = "Filer klar til afhentning Fra PBS Test"; email.Body = MailBody; #else email.Subject = "Filer klar til afhentning Fra PBS"; email.Body = MailBody; #endif email.AddTo(Program.MailToName, Program.MailToAddr); email.From = Program.MailFrom; email.ReplyTo = Program.MailReply; success = mailman.SendEmail(email); if (success != true) { throw new Exception(email.LastErrorText); } }
public string Connect(string yahooEmail, string yahooPassword) { iMap.UnlockComponent("THEBACIMAPMAILQ_OtWKOHoF1R0Q"); iMap.Connect("imap.n.mail.yahoo.com"); //iMap.Login("*****@*****.**", "rga77qViNIV"); iMap.Login(yahooEmail, yahooPassword); iMap.SelectMailbox("Inbox"); // Get a message set containing all the message IDs // in the selected mailbox. Chilkat.MessageSet msgSet; msgSet = iMap.Search("ALL", true); // Fetch all the mail into a bundle object. Chilkat.Email email = new Chilkat.Email(); //bundle = iMap.FetchBundle(msgSet); for (int i = msgSet.Count - 1; i > 0; i--) { email = iMap.FetchSingle(msgSet.GetId(i), true); if (email.Subject.Contains("Action Required: Confirm Your Facebook Account")) { int startIndex = email.Body.IndexOf("http://www.facebook.com/confirmemail.php?e="); int endIndex = email.Body.IndexOf(">", startIndex) - 1; string activationLink = email.Body.Substring(startIndex, endIndex - startIndex).Replace("\r\n", ""); activationLink = activationLink.Replace("3D", "").Replace("hotmai=l", "hotmail").Replace("%40", "@"); string decodedActivationLink = System.Web.HttpUtility.UrlDecode(activationLink); return(decodedActivationLink); } } return(string.Empty); //if (email.) //{ //} }
public void GetFBMails(string yahooEmail, string yahooPassword) { Username = yahooEmail; Password = yahooPassword; //Username = "******"; //Password = "******"; iMap.UnlockComponent("THEBACIMAPMAILQ_OtWKOHoF1R0Q"); //iMap. //iMap.HttpProxyHostname = "127.0.0.1"; //iMap.HttpProxyPort = 8888; iMap.Connect("imap.n.mail.yahoo.com"); iMap.Login(yahooEmail, yahooPassword); iMap.SelectMailbox("Inbox"); // Get a message set containing all the message IDs // in the selected mailbox. Chilkat.MessageSet msgSet; //msgSet = iMap.Search("FROM \"facebookmail.com\"", true); msgSet = iMap.GetAllUids(); // Fetch all the mail into a bundle object. Chilkat.Email email = new Chilkat.Email(); //bundle = iMap.FetchBundle(msgSet); string strEmail = string.Empty; List<string> lstData = new List<string>(); if (msgSet != null) { for (int i = msgSet.Count; i > 0; i--) { email = iMap.FetchSingle(msgSet.GetId(i), true); strEmail = email.Subject; string emailHtml = email.GetHtmlBody(); lstData.Add(strEmail); if (email.Subject.Contains("Action Required: Confirm Your Facebook Account")) { foreach (string href in GetUrlsFromString(email.Body)) { try { string staticUrl = string.Empty; string email_open_log_picUrl = string.Empty; string strBody = email.Body; string[] arr = Regex.Split(strBody, "src="); foreach (string item in arr) { if (!item.Contains("<!DOCTYPE")) { if (item.Contains("static")) { string[] arrStatic = item.Split('"'); staticUrl = arrStatic[1]; } if (item.Contains("email_open_log_pic")) { string[] arrlog_pic = item.Split('"'); email_open_log_picUrl = arrlog_pic[1]; email_open_log_picUrl = email_open_log_picUrl.Replace("amp;", ""); break; } } } string href1 = href.Replace("&report=1", ""); href1 = href.Replace("amp;", ""); //LoginVerfy(href1, staticUrl, email_open_log_picUrl); break; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } //return; } else if (email.Subject.Contains("Just one more step to get started on Facebook")) { foreach (string href in GetUrlsFromString(email.Body)) { try { string staticUrl = string.Empty; string email_open_log_picUrl = string.Empty; string strBody = email.Body; string[] arr = Regex.Split(strBody, "src="); foreach (string item in arr) { if (!item.Contains("<!DOCTYPE")) { if (item.Contains("static")) { string[] arrStatic = item.Split('"'); staticUrl = arrStatic[1]; } if (item.Contains("email_open_log_pic")) { string[] arrlog_pic = item.Split('"'); email_open_log_picUrl = arrlog_pic[1]; email_open_log_picUrl = email_open_log_picUrl.Replace("amp;", ""); break; } } } string href1 = href.Replace("&report=1", ""); href1 = href.Replace("amp;", ""); //LoginVerfy(href1, staticUrl, email_open_log_picUrl); break; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } //return; } } } }
public void fetchMessage(SmtpConfig smtpAcct) { string Username; string Password; string Host; int Port; string Email; bool SSL; bool TSL; long authenticationType; Chilkat.MailMan mailman = new Chilkat.MailMan(); bool success = mailman.UnlockComponent("BARTMNMAILQ_3K24X6hk7C2J"); if (!success) { MessageBox.Show("Could not initialize email component"); return; } if (smtpAcct != null) { Username = smtpAcct.in_userName; Password = smtpAcct.in_password; Host = smtpAcct.in_server; Port = smtpAcct.in_port; Email = smtpAcct.emailAddress; SSL = smtpAcct.in_SSL; TSL = smtpAcct.in_TSL; authenticationType = smtpAcct.in_authentication; } else { GlobalShared.Log.Log((int)LogClass.logType.Warning, "No POP configuration found", false); return; } mailman.MailHost = Host; //TCP port for connection mailman.MailPort = (ushort)Port; //Username to login to the POP3 server mailman.PopUsername = Username; //Password to login to the POP3 server mailman.PopPassword = Password; // SSL Interaction type if (TSL) { mailman.StartTLS = true; } else if (SSL) { mailman.PopSsl = true; } try { _emailMessage = mailman.FetchEmail(_UID); _message = _emailMessage.GetPlainTextBody(); } catch (System.Exception ex) { } finally { mailman = null; } }
/// <summary> /// Gets into Yahoo Email and fetches Activation Link and Sends Http Request to it /// Calls LoginVerfy() which sends Http Request /// Also sends sends Request to gif URL, and 2 more URLs /// </summary> /// <param name="yahooEmail"></param> /// <param name="yahooPassword"></param> public void GetFBMails(string yahooEmail, string yahooPassword) { try { string realEmail = yahooEmail; if (yahooEmail.Contains("+") || yahooEmail.Contains("%2B")) { try { string replacePart = yahooEmail.Substring(yahooEmail.IndexOf("+"), (yahooEmail.IndexOf("@", yahooEmail.IndexOf("+")) - yahooEmail.IndexOf("+"))).Replace("+", string.Empty); yahooEmail = yahooEmail.Replace("+", string.Empty).Replace("%2B", string.Empty).Replace(replacePart, string.Empty); } catch { } } Username = yahooEmail; Password = yahooPassword; //Username = "******"; //Password = "******"; iMap.UnlockComponent("THEBACIMAPMAILQ_OtWKOHoF1R0Q"); //iMap. //iMap.HttpProxyHostname = "127.0.0.1"; //iMap.HttpProxyPort = 8888; iMap.Connect("imap.n.mail.yahoo.com"); iMap.Login(yahooEmail, yahooPassword); iMap.SelectMailbox("Inbox"); // Get a message set containing all the message IDs // in the selected mailbox. Chilkat.MessageSet msgSet; //msgSet = iMap.Search("FROM \"facebookmail.com\"", true); msgSet = iMap.GetAllUids(); // Fetch all the mail into a bundle object. Chilkat.Email email = new Chilkat.Email(); //bundle = iMap.FetchBundle(msgSet); string strEmail = string.Empty; List<string> lstData = new List<string>(); if (msgSet != null) { for (int i = msgSet.Count; i > 0; i--) { email = iMap.FetchSingle(msgSet.GetId(i), true); strEmail = email.Subject; string emailHtml = email.GetHtmlBody(); lstData.Add(strEmail); if (email.Subject.Contains("Action Required: Confirm Your Facebook Account")) { foreach (string href in GetUrlsFromString(email.Body)) { try { string staticUrl = string.Empty; string email_open_log_picUrl = string.Empty; string strBody = email.Body; string[] arr = Regex.Split(strBody, "src="); // string[] arr = Regex.Split(strBody, "href="); foreach (string item in arr) { if (!item.Contains("<!DOCTYPE")) { if (item.Contains("static")) { string[] arrStatic = item.Split('"'); staticUrl = arrStatic[1]; } if (item.Contains("email_open_log_pic")) { string[] arrlog_pic = item.Split('"'); email_open_log_picUrl = arrlog_pic[1]; email_open_log_picUrl = email_open_log_picUrl.Replace("amp;", ""); break; } } } string href1 = href.Replace("&report=1", ""); href1 = href.Replace("amp;", ""); EmailVerificationMultithreaded(href1, staticUrl, email_open_log_picUrl, realEmail, yahooPassword, proxyAddress, proxyPort, proxyUser, proxyPass); //LoginVerfy(href1, staticUrl, email_open_log_picUrl); break; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } //return; } else if (email.Subject.Contains("Just one more step to get started on Facebook")) { foreach (string href in GetUrlsFromString(email.Body)) { try { string staticUrl = string.Empty; string email_open_log_picUrl = string.Empty; string verifyhref = string.Empty; string strBody = email.Body; string[] arr = Regex.Split(strBody, "src="); string[] arr1 = Regex.Split(strBody, "href="); foreach (string item in arr) { if (!item.Contains("<!DOCTYPE")) { if (item.Contains("static")) { string[] arrStatic = item.Split('"'); staticUrl = arrStatic[1]; } if (item.Contains("email_open_log_pic")) { string[] arrlog_pic = item.Split('"'); email_open_log_picUrl = arrlog_pic[1]; email_open_log_picUrl = email_open_log_picUrl.Replace("amp;", ""); break; } } } foreach (string item1 in arr1) { if (item1.Contains("confirmemail.php")) { string[] itemurl = Regex.Split(item1, "\""); verifyhref = itemurl[1].Replace("\"", string.Empty); } } string href1 = verifyhref.Replace("&report=1", ""); string href11 = href1.Replace("amp;", ""); //string href1 = href.Replace("&report=1", ""); //href1 = href.Replace("amp;", ""); if (href.Contains("confirmemail.php") && email_open_log_picUrl.Contains("email_open_log_pic.php")) { EmailVerificationMultithreaded(href11, staticUrl, email_open_log_picUrl, realEmail, yahooPassword, proxyAddress, proxyPort, proxyUser, proxyPass); //LoginVerfy(href1, staticUrl, email_open_log_picUrl); break; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } //return; } //*****************************************************bysanjeev********************** else if (email.Subject.Contains("Facebook Email Verification")) { foreach (string href in GetUrlsFromString(email.Body)) { try { string staticUrl = string.Empty; string email_open_log_picUrl = string.Empty; string verifyhref = string.Empty; string strBody = email.Body; string[] arr = Regex.Split(strBody, "src="); string[] arr1 = Regex.Split(strBody, "href="); // string[] arr = Regex.Split(strBody, "src="); foreach (string item in arr) { if (!item.Contains("<!DOCTYPE")) { if (item.Contains("static")) { string[] arrStatic = item.Split('"'); staticUrl = arrStatic[1]; } if (item.Contains("email_open_log_pic")) { string[] arrlog_pic = item.Split('"'); email_open_log_picUrl = arrlog_pic[1]; email_open_log_picUrl = email_open_log_picUrl.Replace("amp;", ""); break; } } } foreach (string item1 in arr1) { if (item1.Contains("confirmcontact.php")) { string[] itemurl = Regex.Split(item1, "\""); verifyhref = itemurl[1].Replace("\"", string.Empty); } } //string href1 = href.Replace("&report=1", ""); //href1 = href.Replace("&", ""); if (href.Contains("confirmcontact.php") && email_open_log_picUrl.Contains("email_open_log_pic.php")) { EmailVerificationMultithreaded(verifyhref, staticUrl, email_open_log_picUrl, realEmail, yahooPassword, proxyAddress, proxyPort, proxyUser, proxyPass); break; }//LoginVerfy(href1, staticUrl, email_open_log_picUrl); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } //return; } //**************************************************************************************** } } } catch (Exception ex) { GlobusLogHelper.log.Error("Error : " + ex.StackTrace); } }
public bool EmailVerification(string Email, string Password, ref GlobusHttpHelper globushttpHelper) { bool IsActivated = false; try { Log("[ " + DateTime.Now + " ] => [ Please Wait Account Verification Start... ]"); System.Windows.Forms.Application.DoEvents(); Chilkat.Http http = new Chilkat.Http(); if (Email.Contains("@yahoo")) { #region Yahoo Verification Steps GlobusHttpHelper HttpHelper = new GlobusHttpHelper(); bool activate = false; try { bool emaildata = false; //Chilkat.Http http = new Chilkat.Http(); ///Chilkat Http Request to be used in Http Post... Chilkat.HttpRequest req = new Chilkat.HttpRequest(); bool success; // Any string unlocks the component for the 1st 30-days. success = http.UnlockComponent("THEBACHttp_b3C9o9QvZQ06"); if (success != true) { Console.WriteLine(http.LastErrorText); return false; } http.CookieDir = "memory"; http.SendCookies = true; http.SaveCookies = true; //http.ProxyDomain = "127.0.0.1"; //http.ProxyPort = 8888; http.SetRequestHeader("Accept-Encoding", "gzip,deflate"); Chilkat.Imap iMap = new Imap(); string Username = Email; iMap.UnlockComponent("THEBACIMAPMAILQ_OtWKOHoF1R0Q"); //iMap. //iMap.HttpProxyHostname = "127.0.0.1"; //iMap.HttpProxyPort = 8888; iMap.Port = 993; iMap.Connect("imap.n.mail.yahoo.com"); iMap.Login(Email, Password); iMap.SelectMailbox("Inbox"); // Get a message set containing all the message IDs // in the selected mailbox. Chilkat.MessageSet msgSet; //msgSet = iMap.Search("FROM \"facebookmail.com\"", true); msgSet = iMap.GetAllUids(); if (msgSet.Count <= 0) { msgSet = iMap.GetAllUids(); } // Fetch all the mail into a bundle object. Chilkat.Email email = new Chilkat.Email(); //bundle = iMap.FetchBundle(msgSet); string strEmail = string.Empty; List<string> lstData = new List<string>(); if (msgSet != null) { for (int i = 0; i < msgSet.Count; i++) { try { email = iMap.FetchSingle(msgSet.GetId(i), true); strEmail = email.Subject; string emailHtml = email.GetHtmlBody(); lstData.Add(strEmail); string from = email.From.ToString().ToLower(); if (from.Contains("@linkedin.com")) { foreach (string href in GetUrlsFromString(email.Body)) { try { if (href.Contains("http://www.linkedin.com/e/csrf") || href.Contains("http://www.linkedin.com/e/ato") || href.Contains("http://www.linkedin.com/e/v2?e")) { string EscapeEmail = Uri.EscapeDataString(Email).Replace(".", "%2E").Trim(); { string ConfirmationResponse = globushttpHelper.getHtmlfromUrl1(new Uri(href)); IsActivated = true; break; } } } catch (Exception ex) { Console.WriteLine("6 :" + ex.StackTrace); } } } if (IsActivated) { Log("[ " + DateTime.Now + " ] => [ Account : " + Email + " verified ]"); break; } } catch (Exception ex) { Console.WriteLine("Error >>> " + ex.StackTrace); } } } } catch (Exception ex) { Console.WriteLine("7 :" + ex.StackTrace); Log("[ " + DateTime.Now + " ] => [ Email Verification Exception : " + ex.Message + "StackTrace --> >>>" + ex.StackTrace + " with : " + Email + " ]"); Log("[ " + DateTime.Now + " ] => [ Please check your Login Id and Password ]"); } return IsActivated; #endregion } else { string Host = string.Empty; int Port = 0; if (Email.Contains("@gmail")) { Host = "pop.gmail.com"; Port = 995; } else if (Email.Contains("@hotmail")) { Host = "pop3.live.com"; Port = 995; } else if (Email.Contains("@gmx")) { Host = "pop.gmx.com"; Port = 995; } if (!string.IsNullOrEmpty(Host)) { try { if (popClient.Connected) popClient.Disconnect(); popClient.Connect(Host, Port, true); popClient.Authenticate(Email, Password); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); //retry once System.Threading.Thread.Sleep(1000); if (popClient.Connected) popClient.Disconnect(); popClient.Connect(Host, Port, true); popClient.Authenticate(Email, Password); } //if (!) //{ //} int Count = popClient.GetMessageCount(); for (int i = Count; i >= 1; i--) { try { OpenPOP.MIME.Message Message = popClient.GetMessage(i); string subject = string.Empty; subject = Message.Headers.Subject; string frowwm = Message.Headers.From.ToString(); bool GoIntoEmail = false; if (string.IsNullOrEmpty(subject)) { string from = Message.Headers.From.ToString().ToLower(); if (from.Contains("linkedin.com")) { GoIntoEmail = true; } } try { if (frowwm.Contains("linkedin.com")) //if(GoIntoEmail) { string Messagebody = Message.MessageBody[0]; foreach (string href in GetUrlsFromStringGmail(Messagebody)) { try { if (href.Contains("http://www.linkedin.com/e/csrf") || href.Contains("http://www.linkedin.com/e/ato") || href.Contains("http://www.linkedin.com/e/v2?e")) { string href1 = href.Replace("amp;",string.Empty); string EscapeEmail = Uri.EscapeDataString(Email).Replace(".", "%2E").Trim(); { string ConfirmationResponse = globushttpHelper.getHtmlfromUrl1(new Uri(href1)); IsActivated = true; break; } } } catch (Exception ex) { Console.WriteLine("5 :" + ex.StackTrace); }; } } } catch (Exception ex) { Console.WriteLine("10 :" + ex.StackTrace); Log("[ " + DateTime.Now + " ] => [ Email Verification Exception : " + ex.Message + "StackTrace --> >>>" + ex.StackTrace + " with : " + Email + " ]"); } if (IsActivated) { break; } } catch (Exception ex) { { Log("[ " + DateTime.Now + " ] => [ Email Verification Exception : " + ex.Message + "StackTrace --> >>>" + ex.StackTrace + " with : " + Email + " ]"); Log("[ " + DateTime.Now + " ] => [ Please check your Login Id and Password ]"); } } } } } return IsActivated; } catch (Exception ex) { Console.WriteLine("4 :" + ex.StackTrace); return IsActivated; } }
public bool GetYahooMails(string yahooEmail, string yahooPassword) { GlobusHttpHelper HttpHelper = new GlobusHttpHelper(); bool activate = false; try { bool emaildata = false; Chilkat.Http http = new Chilkat.Http(); ///Chilkat Http Request to be used in Http Post... Chilkat.HttpRequest req = new Chilkat.HttpRequest(); bool success; // Any string unlocks the component for the 1st 30-days. success = http.UnlockComponent("THEBACHttp_b3C9o9QvZQ06"); if (success != true) { Console.WriteLine(http.LastErrorText); return false; } http.CookieDir = "memory"; http.SendCookies = true; http.SaveCookies = true; //http.ProxyDomain = "127.0.0.1"; //http.ProxyPort = 8888; http.SetRequestHeader("Accept-Encoding", "gzip,deflate"); Chilkat.Imap iMap = new Imap(); string Username = yahooEmail; string Password = yahooPassword; //Username = "******"; //Password = "******"; iMap.UnlockComponent("THEBACIMAPMAILQ_OtWKOHoF1R0Q"); //iMap. //iMap.HttpProxyHostname = "127.0.0.1"; //iMap.HttpProxyPort = 8888; iMap.Connect("imap.n.mail.yahoo.com"); iMap.Login(yahooEmail, yahooPassword); iMap.SelectMailbox("Inbox"); // Get a message set containing all the message IDs // in the selected mailbox. Chilkat.MessageSet msgSet; //msgSet = iMap.Search("FROM \"facebookmail.com\"", true); msgSet = iMap.GetAllUids(); // Fetch all the mail into a bundle object. Chilkat.Email email = new Chilkat.Email(); //bundle = iMap.FetchBundle(msgSet); string strEmail = string.Empty; List<string> lstData = new List<string>(); if (msgSet != null) { for (int i = msgSet.Count; i > 0; i--) { email = iMap.FetchSingle(msgSet.GetId(i), true); strEmail = email.Subject; string emailHtml = email.GetHtmlBody(); lstData.Add(strEmail); if (email.Subject.Contains("[WordPress] Activate") && email.Subject.Contains("wordpress.com")) { foreach (string href in GetUrlsFromString(email.Body)) { try { string staticUrl = string.Empty; staticUrl = href; responce = http.QuickGetStr(staticUrl); if (responce.Contains("Your account is now active")) { emaildata = true; //Log("your Account is activate now"); activate = true; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } } } if (emaildata == false) { Log("[ " + DateTime.Now + " ] => [ activation link is not find in user account so your Account is not activate please activate now ]"); } } catch (Exception ex) { } return activate; }
public bool EmailVerification(string Email, string Password, ref GlobusHttpHelper globushttpHelper) { bool IsActivated = false; try { Log("[ " + DateTime.Now + " ] => [ Please Wait Account Verification Start... ]"); System.Windows.Forms.Application.DoEvents(); Chilkat.Http http = new Chilkat.Http(); if (Email.Contains("@yahoo")) { #region Yahoo Verification Steps GlobusHttpHelper HttpHelper = new GlobusHttpHelper(); bool activate = false; try { bool emaildata = false; //Chilkat.Http http = new Chilkat.Http(); ///Chilkat Http Request to be used in Http Post... Chilkat.HttpRequest req = new Chilkat.HttpRequest(); bool success; // Any string unlocks the component for the 1st 30-days. success = http.UnlockComponent("THEBACHttp_b3C9o9QvZQ06"); if (success != true) { Console.WriteLine(http.LastErrorText); return(false); } http.CookieDir = "memory"; http.SendCookies = true; http.SaveCookies = true; //http.ProxyDomain = "127.0.0.1"; //http.ProxyPort = 8888; http.SetRequestHeader("Accept-Encoding", "gzip,deflate"); Chilkat.Imap iMap = new Imap(); string Username = Email; iMap.UnlockComponent("THEBACIMAPMAILQ_OtWKOHoF1R0Q"); //iMap. //iMap.HttpProxyHostname = "127.0.0.1"; //iMap.HttpProxyPort = 8888; iMap.Port = 993; iMap.Connect("imap.n.mail.yahoo.com"); iMap.Login(Email, Password); iMap.SelectMailbox("Inbox"); // Get a message set containing all the message IDs // in the selected mailbox. Chilkat.MessageSet msgSet; //msgSet = iMap.Search("FROM \"facebookmail.com\"", true); msgSet = iMap.GetAllUids(); if (msgSet.Count <= 0) { msgSet = iMap.GetAllUids(); } // Fetch all the mail into a bundle object. Chilkat.Email email = new Chilkat.Email(); //bundle = iMap.FetchBundle(msgSet); string strEmail = string.Empty; List <string> lstData = new List <string>(); if (msgSet != null) { for (int i = 0; i < msgSet.Count; i++) { try { email = iMap.FetchSingle(msgSet.GetId(i), true); strEmail = email.Subject; string emailHtml = email.GetHtmlBody(); lstData.Add(strEmail); string from = email.From.ToString().ToLower(); if (from.Contains("@linkedin.com")) { foreach (string href in GetUrlsFromString(email.Body)) { try { if (href.Contains("http://www.linkedin.com/e/csrf") || href.Contains("http://www.linkedin.com/e/ato") || href.Contains("http://www.linkedin.com/e/v2?e")) { string EscapeEmail = Uri.EscapeDataString(Email).Replace(".", "%2E").Trim(); { string ConfirmationResponse = globushttpHelper.getHtmlfromUrl1(new Uri(href)); IsActivated = true; break; } } } catch (Exception ex) { Console.WriteLine("6 :" + ex.StackTrace); } } } if (IsActivated) { Log("[ " + DateTime.Now + " ] => [ Account : " + Email + " verified ]"); break; } } catch (Exception ex) { Console.WriteLine("Error >>> " + ex.StackTrace); } } } } catch (Exception ex) { Console.WriteLine("7 :" + ex.StackTrace); Log("[ " + DateTime.Now + " ] => [ Email Verification Exception : " + ex.Message + "StackTrace --> >>>" + ex.StackTrace + " with : " + Email + " ]"); Log("[ " + DateTime.Now + " ] => [ Please check your Login Id and Password ]"); } return(IsActivated); #endregion } else { string Host = string.Empty; int Port = 0; if (Email.Contains("@gmail")) { Host = "pop.gmail.com"; Port = 995; } else if (Email.Contains("@hotmail")) { Host = "pop3.live.com"; Port = 995; } else if (Email.Contains("@gmx")) { Host = "pop.gmx.com"; Port = 995; } if (!string.IsNullOrEmpty(Host)) { try { if (popClient.Connected) { popClient.Disconnect(); } popClient.Connect(Host, Port, true); popClient.Authenticate(Email, Password); } catch (Exception ex) { Console.WriteLine(ex.StackTrace); //retry once System.Threading.Thread.Sleep(1000); if (popClient.Connected) { popClient.Disconnect(); } popClient.Connect(Host, Port, true); popClient.Authenticate(Email, Password); } //if (!) //{ //} int Count = popClient.GetMessageCount(); for (int i = Count; i >= 1; i--) { try { OpenPOP.MIME.Message Message = popClient.GetMessage(i); string subject = string.Empty; subject = Message.Headers.Subject; string frowwm = Message.Headers.From.ToString(); bool GoIntoEmail = false; if (string.IsNullOrEmpty(subject)) { string from = Message.Headers.From.ToString().ToLower(); if (from.Contains("linkedin.com")) { GoIntoEmail = true; } } try { if (frowwm.Contains("linkedin.com")) //if(GoIntoEmail) { string Messagebody = Message.MessageBody[0]; foreach (string href in GetUrlsFromStringGmail(Messagebody)) { try { if (href.Contains("http://www.linkedin.com/e/csrf") || href.Contains("http://www.linkedin.com/e/ato") || href.Contains("http://www.linkedin.com/e/v2?e")) { string href1 = href.Replace("amp;", string.Empty); string EscapeEmail = Uri.EscapeDataString(Email).Replace(".", "%2E").Trim(); { string ConfirmationResponse = globushttpHelper.getHtmlfromUrl1(new Uri(href1)); IsActivated = true; break; } } } catch (Exception ex) { Console.WriteLine("5 :" + ex.StackTrace); }; } } } catch (Exception ex) { Console.WriteLine("10 :" + ex.StackTrace); Log("[ " + DateTime.Now + " ] => [ Email Verification Exception : " + ex.Message + "StackTrace --> >>>" + ex.StackTrace + " with : " + Email + " ]"); } if (IsActivated) { break; } } catch (Exception ex) { { Log("[ " + DateTime.Now + " ] => [ Email Verification Exception : " + ex.Message + "StackTrace --> >>>" + ex.StackTrace + " with : " + Email + " ]"); Log("[ " + DateTime.Now + " ] => [ Please check your Login Id and Password ]"); } } } } } return(IsActivated); } catch (Exception ex) { Console.WriteLine("4 :" + ex.StackTrace); return(IsActivated); } }
public bool EmailVerification(string Email, string Password, ref GlobusHttpHelper globushttpHelper) { bool IsActivated = false; try { System.Windows.Forms.Application.DoEvents(); Chilkat.Http http = new Chilkat.Http(); if (Email.Contains("+")) { String[] emaildata = Email.Split('+'); Email = (emaildata[0] + "@" + emaildata[1].Split('@')[1]).Trim(); } if (Email.Contains("@yahoo")) { #region Yahoo Verification Steps GlobusHttpHelper HttpHelper = new GlobusHttpHelper(); bool activate = false; try { bool emaildata = false; //Chilkat.Http http = new Chilkat.Http(); ///Chilkat Http Request to be used in Http Post... Chilkat.HttpRequest req = new Chilkat.HttpRequest(); bool success; // Any string unlocks the component for the 1st 30-days. success = http.UnlockComponent("THEBACHttp_b3C9o9QvZQ06"); if (success != true) { Console.WriteLine(http.LastErrorText); return(false); } http.CookieDir = "memory"; http.SendCookies = true; http.SaveCookies = true; //http.IPDomain = "127.0.0.1"; //http.IPPort = 8888; http.SetRequestHeader("Accept-Encoding", "gzip,deflate"); Chilkat.Imap iMap = new Imap(); string Username = Email; iMap.UnlockComponent("THEBACIMAPMAILQ_OtWKOHoF1R0Q"); //iMap. //iMap.HttpIPHostname = "127.0.0.1"; //iMap.HttpIPPort = 8888; iMap.Port = 993; iMap.Connect("imap.n.mail.yahoo.com"); iMap.Login(Email, Password); iMap.SelectMailbox("Inbox"); // Get a message set containing all the message IDs // in the selected mailbox. Chilkat.MessageSet msgSet; //msgSet = iMap.Search("FROM \"facebookmail.com\"", true); msgSet = iMap.GetAllUids(); if (msgSet.Count <= 0) { msgSet = iMap.GetAllUids(); } // Fetch all the mail into a bundle object. Chilkat.Email email = new Chilkat.Email(); //bundle = iMap.FetchBundle(msgSet); string strEmail = string.Empty; List <string> lstData = new List <string>(); if (msgSet != null) { for (int i = msgSet.Count; i > 0; i--) //for (int i = 0; i < msgSet.Count; i++) { try { email = iMap.FetchSingle(msgSet.GetId(i), true); strEmail = email.Subject; string emailHtml = email.GetHtmlBody(); lstData.Add(strEmail); string from = email.From.ToString().ToLower(); if (from.Contains("twitter.com") || from.Contains("account-verification")) { #region <old User Parser //foreach (string href in GetUrlsFromString(email.Body)) //{ // try // { // if (href.Contains("https://twitter.com/account/confirm_email/") ) // { // string ConfirmationResponse = globushttpHelper.getHtmlfromUrl(new Uri(href), "", ""); // IsActivated = true; // } // } // catch (Exception ex) // { // Console.WriteLine("6 :" + ex.StackTrace); // } //} #endregion string[] arr = Regex.Split(email.Body, "href"); foreach (string strhref in arr) { if (!strhref.Contains("<!DOCTYPE")) { if (strhref.Contains("https://twitter.com/account/confirm_email")) { string AncherTag = System.Text.RegularExpressions.Regex.Split(strhref, ">")[1]; string tempString = AncherTag.Substring(AncherTag.IndexOf("https")); string DataUrl = tempString.Replace("<>", "").Replace(">", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty).Replace("</a", string.Empty); string ConfirmationResponse = globushttpHelper.getHtmlfromUrl(new Uri(DataUrl), "", ""); IsActivated = true; break; } } } } if (IsActivated) { Log("[ " + DateTime.Now + " ] => [ Account : " + Email + " verified ]"); break; } } catch { }; } } } catch (Exception ex) { Console.WriteLine("7 :" + ex.StackTrace); Log("[ " + DateTime.Now + " ] => [ Email Verification Exception : " + ex.Message + " with : " + Email + " ]"); } return(IsActivated); #endregion } else { string Host = string.Empty; int Port = 0; if (Email.Contains("@gmail")) { Host = "pop.gmail.com"; Port = 995; } else if (Email.Contains("@hotmail")) { Host = "pop3.live.com"; Port = 995; } else if (Email.Contains("@gmx")) { Host = "pop.gmx.com"; Port = 995; } if (!string.IsNullOrEmpty(Host)) { if (popClient.Connected) { popClient.Disconnect(); } popClient.Connect(Host, Port, true); popClient.Authenticate(Email, Password); int Count = popClient.GetMessageCount(); for (int i = Count; i >= 1; i--) { try { OpenPOP.MIME.Message Message = popClient.GetMessage(i); string subject = string.Empty; subject = Message.Headers.Subject; bool GoIntoEmail = false; if (string.IsNullOrEmpty(subject)) { string from = Message.Headers.From.ToString().ToLower(); if (from.Contains("twitter.com")) { GoIntoEmail = true; } } try { if (GoIntoEmail || subject.Contains("Twitter")) //if(GoIntoEmail) { string Messagebody = Message.MessageBody[0]; foreach (string href in GetUrlsFromStringGmail(Messagebody)) { try { if (href.Contains("https://twitter.com/account/confirm_email/")) { string ConfirmationResponse = globushttpHelper.getHtmlfromUrl(new Uri(href), "", ""); IsActivated = true; break; } } catch (Exception ex) { Console.WriteLine("5 :" + ex.StackTrace); }; } } } catch (Exception ex) { Console.WriteLine("10 :" + ex.StackTrace); Log("[ " + DateTime.Now + " ] => [ Email Verification Exception : " + ex.Message + " with : " + Email + " ]"); } if (IsActivated) { break; } } catch (Exception ex) { Log("[ " + DateTime.Now + " ] => [ Email Verification Exception : " + ex.Message + " with : " + Email + " ]"); } } } } return(IsActivated); } catch (Exception ex) { Console.WriteLine("4 :" + ex.StackTrace); return(IsActivated); } }
public IList <Email> GetAllMails(string fromEmailID) { IList <Email> emails = new List <Email>(); using (Chilkat.Imap imap = new Imap()) { if (imap.UnlockComponent("EASYDAIMAPMAILQ_vcyhVCXs2N0G")) { if (connectToIMAPMailServer(imap)) { Chilkat.MessageSet messageSet = null; bool fetchUids = false; // Select an IMAP mailbox success = imap.SelectMailbox("Inbox"); if (success != true) { //Debug.WriteLine(imap.LastErrorText); return(null); } messageSet = imap.Search(string.Format("FROM {0}", fromEmailID), fetchUids); /*if (success != true) * { * Logger.LogDebug(imap.LastErrorText); * return null; * }*/ //if (imap.LastMethodSuccess == false) //{ // //Debug.WriteLine(imap.LastErrorText); // return null; //} //bool bUid = false; //string mimeStr; //int n = imap.NumMessages; Chilkat.EmailBundle bundle = null; bundle = imap.FetchBundle(messageSet); int i = 0; while (i < bundle.MessageCount) { Chilkat.Email email = null; email = bundle.GetEmail(i); emails.Add(email); //DataRow drEmail = dtEmails.NewRow(); //drEmail["From"] = email.From; //drEmail["FromAddress"] = email.FromAddress; //drEmail["FromName"] = email.FromName; ////drEmail["To"] = email.; //drEmail["LocalDate"] = email.LocalDate; //drEmail["Subject"] = email.Subject; //drEmail["Body"] = email.Body; //drEmail["NumAttachedMessages"] = email.NumAttachments; //drEmail["Size"] = email.Size; //drEmail["NumDaysOld"] = email.NumDaysOld; //dtEmails.Rows.Add(drEmail); i = i + 1; } // An alternative is to download each email in the form of an // email object, like this: //Chilkat.Email email = null; //for (int i = 1; i <= n; i++) //{ // // Download the email by sequence number. // email = imap.FetchSingle(i, bUid); // emails.Add(email); // if (i > 100) // break; // // ... your application may process the email object... //} // Disconnect from the IMAP server. success = imap.Disconnect(); //bool fetchUids = false; //string fetchEmailCriteria = "ALL"; //Chilkat.MessageSet messageSet = new MessageSet(); //messageSet = imap.Search(fetchEmailCriteria, fetchUids); //if (messageSet == null) //{ // Logger.LogDebug("Unable to fetch email from mail server."); // return null; //} //EmailBundle emailBundle = imap.FetchBundle(messageSet); //if (emailBundle == null) //{ // Logger.LogDebug("Unable to fetch email from mail server."); // return null; //} //for (int i = 0; i <= emailBundle.MessageCount -1;i++) //{ // emailBundle.SortByDate(true); // Email email = emailBundle.GetEmail(i); // emails.Add(email); //} } } } return(emails); }
/// <summary> /// Gets into Yahoo Email and fetches Activation Link and Sends Http Request to it /// Calls LoginVerfy() which sends Http Request /// Also sends sends Request to gif URL, and 2 more URLs /// </summary> /// <param name="yahooEmail"></param> /// <param name="yahooPassword"></param> #region GetFBMails public void GetFBMails(string yahooEmail, string yahooPassword) { Username = yahooEmail; Password = yahooPassword; //Username = "******"; //Password = "******"; iMap.UnlockComponent("THEBACIMAPMAILQ_OtWKOHoF1R0Q"); //iMap. //iMap.HttpProxyHostname = "127.0.0.1"; //iMap.HttpProxyPort = 8888; iMap.Connect("imap.n.mail.yahoo.com"); iMap.Login(yahooEmail, yahooPassword); iMap.SelectMailbox("Inbox"); // Get a message set containing all the message IDs // in the selected mailbox. Chilkat.MessageSet msgSet; //msgSet = iMap.Search("FROM \"facebookmail.com\"", true); msgSet = iMap.GetAllUids(); // Fetch all the mail into a bundle object. Chilkat.Email email = new Chilkat.Email(); //bundle = iMap.FetchBundle(msgSet); string strEmail = string.Empty; List <string> lstData = new List <string>(); if (msgSet != null) { for (int i = msgSet.Count; i > 0; i--) { email = iMap.FetchSingle(msgSet.GetId(i), true); strEmail = email.Subject; string emailHtml = email.GetHtmlBody(); lstData.Add(strEmail); if (email.Subject.Contains("Action Required: Confirm Your Facebook Account")) { foreach (string href in GetUrlsFromString(email.Body)) { try { string staticUrl = string.Empty; string email_open_log_picUrl = string.Empty; string strBody = email.Body; string[] arr = Regex.Split(strBody, "src="); foreach (string item in arr) { if (!item.Contains("<!DOCTYPE")) { if (item.Contains("static")) { string[] arrStatic = item.Split('"'); staticUrl = arrStatic[1]; } if (item.Contains("email_open_log_pic")) { string[] arrlog_pic = item.Split('"'); email_open_log_picUrl = arrlog_pic[1]; email_open_log_picUrl = email_open_log_picUrl.Replace("amp;", ""); break; } } } string href1 = href.Replace("&report=1", ""); href1 = href.Replace("amp;", ""); //LoginVerfy(href1, staticUrl, email_open_log_picUrl); break; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } //return; } else if (email.Subject.Contains("Just one more step to get started on Facebook")) { foreach (string href in GetUrlsFromString(email.Body)) { try { string staticUrl = string.Empty; string email_open_log_picUrl = string.Empty; string strBody = email.Body; string[] arr = Regex.Split(strBody, "src="); foreach (string item in arr) { if (!item.Contains("<!DOCTYPE")) { if (item.Contains("static")) { string[] arrStatic = item.Split('"'); staticUrl = arrStatic[1]; } if (item.Contains("email_open_log_pic")) { string[] arrlog_pic = item.Split('"'); email_open_log_picUrl = arrlog_pic[1]; email_open_log_picUrl = email_open_log_picUrl.Replace("amp;", ""); break; } } } string href1 = href.Replace("&report=1", ""); href1 = href.Replace("amp;", ""); //LoginVerfy(href1, staticUrl, email_open_log_picUrl); break; } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } //return; } } } }
public static bool SendEmailWithChilkat(MailMessage mailMessage, string attachfilePath) { //using (Chilkat.Imap imap = new Imap()) //{ Chilkat.MailMan mailman = new Chilkat.MailMan(); mailman.UnlockComponent("EASYDAIMAPMAILQ_vcyhVCXs2N0G"); // Set the SMTP server. mailman.SmtpHost = MailServer.HostName; // Set the SMTP login/password (if required) mailman.SmtpUsername = MailServer.UserName; mailman.SmtpPassword = MailServer.Password; // Connect to SMTP port 465 using TLS. mailman.SmtpSsl = true; mailman.SmtpPort = MailServer.HostPort; // Create a new email object Chilkat.Email email = new Chilkat.Email(); email.Subject = mailMessage.Subject; email.From = mailMessage.From.ToString(); email.Body = mailMessage.Body; //email.Subject = "This is a test"; //email.Body = "This is a test"; //email.From = "*****@*****.**"; bool success = email.AddTo("", mailMessage.To[0].Address.ToString()); if (mailMessage.CC.Count > 0) { success = email.AddCC("", mailMessage.CC[0].Address.ToString()); } // To add more recipients, call AddTo, AddCC, or AddBcc once per recipient. // Add some attachments. // The AddFileAttachment method returns the value of the content-type it chose for the attachment. string contentType = email.AddFileAttachment(attachfilePath); //if (email.LastMethodSuccess != true) //{ // Debug.WriteLine(email.LastErrorText); // return false; //} // Call SendEmail to connect to the SMTP server and send. // The connection (i.e. session) to the SMTP server remains // open so that subsequent SendEmail calls may use the // same connection. success = mailman.SendEmail(email); if (success != true) { Debug.WriteLine(mailman.LastErrorText); throw new Exception(mailman.LastErrorText); } success = mailman.CloseSmtpConnection(); if (success != true) { Debug.WriteLine("Connection to SMTP server not closed cleanly."); } Debug.WriteLine("Mail with attachments sent!"); try { saveEmailToSendItem(email); } catch (Exception ex) { Logger.LogInfo("Error in save email to send item:" + ex.ToString()); } return(true); //} //return true; }
/// <summary> /// Get all the leads from the database and do stuff with them. That doesn't sound very good does it. /// </summary> /// <param name="testLead">(Optional) A test lead to send to rather than DB leads.</param> /// <remarks> /// This should probably go in ApplicationManager with callbacks and stuff for logging. Todo. /// </remarks> private void ProcessNewDatabaseLeads(Lead testLead) { const string genericTeamName = "WARRIORS"; const string defaultTemplateDesc1 = "Football"; const string defaultTemplateDesc2 = "Baseball"; const int customJersyImageWidth = 150; const string imagesSubdir = "images"; const string commonSubdir = "common"; const string tempSubdir = "temp"; const int maxNumLeadsCommonSense = 5; int sendRetries = 0; // // Debugging mode doesn't send emails to leads, but it sends them to a test account. // bool debugging = _settings.DebuggingMode; Log("Processing new leads in db, debugging mode: {0}...", debugging); string errMsg = string.Empty; string outputEmailFile = Functions.BuildFilenameFromElements(_settings.EmailSrcDir, "output-temp.htm"); // // Read header row, then read the row we want. // StreamReader reader = File.OpenText(Functions.BuildFilenameFromElements(_settings.EmailSrcDir, string.Format("lead-email-{0}.htm", _settings.EmailTemplateNo))); string emailTemplateOrig = reader.ReadToEnd(); reader.Close(); // The mailman object is used for sending and receiving email. Chilkat.MailMan mailman = new Chilkat.MailMan(); // The MHT component can be used to convert an HTML page // from a URL, file, or in-memory HTML into an email // with embedded images and style sheets. Chilkat.Mht mht = new Chilkat.Mht(); // Any string argument automatically begins the 30-day trial. bool success; // success = mailman.UnlockComponent(Config.ChilkatUnlockCodeEmail); success = mailman.UnlockComponent(ChilkatRegCodes.ChilkatEmail); if (success != true) { Log("Component unlock failed"); return; } // success = mht.UnlockComponent(Config.ChilkatUnlockCodeEmail); success = mht.UnlockComponent(ChilkatRegCodes.ChilkatMHT); if (success != true) { Log("Mht component unlock failed"); return; } // Set the SMTP server. mailman.SmtpHost = Config.LeadMailboxServer; // Set the SMTP login/password (if required) mailman.SmtpUsername = Config.LeadMailboxLoginUID; mailman.SmtpPassword = Config.LeadMailboxLoginPW; // // Set up parameters to append to all the email links so Google Analytics can track the clicks for us. // Campaign campaign = new Campaign(); // Todo: grab this from the db & config file campaign.Source = "fundraisingweb"; campaign.Medium = (debugging || testLead != null) ? "testing" : "email"; campaign.Content = _settings.EmailTemplateNo; List <Lead> leads; if (testLead == null) { Log("Getting leads from db..."); leads = DataManager.GetNewFundraisingLeads(); } else { leads = new List <Lead>(); leads.Add(testLead); } if (leads.Count > maxNumLeadsCommonSense) { string msg = string.Format("An unusually high amount of leads were returned from the db ({0}), do you wish to send emails anyway?", leads.Count); if (MessageBox.Show(msg, "Sanity Check", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { // Close the program btnClose_Click(null, null); } } foreach (Lead lead in leads) { Log("Processing lead: {0}", lead); if (!_doingProcessing && testLead == null) { // // We were signalled to stop processing // Log("User signalled to quit, exiting..."); return; } string emailTemplate = emailTemplateOrig; //Lead lead = leads[0]; // ApplicationManager.SetFundraisingIdeasProperties(lead); // const int totalNumberOfTemplates = 5; // string templateDescShort = Functions.FirstNonemptyString(lead.TemplateDescShort, "Football"); // // Otherwise, make it 1 so that we put in two different template graphics. // // int altTemplate = lead.TemplateDescShort == string.Empty ? 1 : 0; string customName; if (!Functions.IsEmptyString(lead.LastName) && lead.LastName.Length <= 13) { customName = lead.LastName; } else if (!Functions.IsEmptyString(lead.FirstName) && lead.LastName.Length <= 13) { customName = lead.FirstName; } else { customName = "anyname"; } customName = customName.ToUpper(); string customNumber = string.Format("{0:yy}", DateTime.Now); Template template1 = lead.TemplateCurrent; Template template2 = lead.TemplateCurrent; // If we have a specific template specified, use them both. Otherwise, use the default and another one. if (template1 == null) { template1 = DataManager.GetTemplate(defaultTemplateDesc1); // template2 = DataManager.GetTemplate(((template1.TemplateId + 1) % totalNumberOfTemplates + 1) + 1); template2 = DataManager.GetTemplate(defaultTemplateDesc2); } //Template template1 = DataManager.GetTemplate(templateDescShort); //Template template2 = DataManager.GetTemplate((template1.TemplateId + altTemplate) % totalNumberOfTemplates); PlayerSeason example1 = new PlayerSeason(customName, customNumber); PlayerSeason example2 = new PlayerSeason(genericTeamName, customNumber); example1.TemplateCurrent = template1; example2.TemplateCurrent = template2; string example1File = string.Format("{0}_{1:000}_{2}_{3}.jpg", template1.TemplateDescShort, template1.TemplateId, customName, customNumber); string example1FPath = Functions.BuildFilenameFromElements( _settings.EmailSrcDir, imagesSubdir, tempSubdir, example1File); string example2File = string.Format("{0}_{1:000}_{2}_{3}.jpg", template2.TemplateDescShort, template2.TemplateId, genericTeamName, customNumber); string example2FPath = Functions.BuildFilenameFromElements( _settings.EmailSrcDir, imagesSubdir, commonSubdir, example2File); Log("Creating image: {0}", example1File); ApplicationManager.WritePlayerMarketingGIFFile(example1, customJersyImageWidth, example1FPath, debugging); Log("Creating image: {0}", example2File); ApplicationManager.WritePlayerMarketingGIFFile(example2, customJersyImageWidth, example2FPath, debugging); // // Personalize the email. // Dictionary <string, string> replacements = new Dictionary <string, string>(); replacements.Add("[cust_fname]", Functions.TitleCase(Functions.FirstNonemptyString(lead.FirstName.ToLower(), lead.LastName.ToLower(), "Hi future fundraiser"))); replacements.Add("[current_year_2digit]", customNumber); replacements.Add("[homepage_href]", ApplicationManager.BuildWebsiteLink(null, campaign)); string addtlLi = string.Empty; if (lead.IsAthletics) { addtlLi = string.Format("<li>Your {0} team!</li>", lead.TemplateCurrent.TemplateDescShort); } replacements.Add("[perfect_for_addtl_li]", addtlLi); replacements.Add("[specific_jersey_href]", ApplicationManager.BuildWebsiteLink(example1, campaign)); replacements.Add("[alternate_jersey_href]", ApplicationManager.BuildWebsiteLink(example2, campaign)); replacements.Add("[specific_jersey_image]", Functions.BuildUrlFromElements(imagesSubdir, tempSubdir, example1File)); replacements.Add("[alternate_jersey_image]", Functions.BuildUrlFromElements(imagesSubdir, commonSubdir, example2File)); replacements.Add("[homepage_href_fundraisingpage]", ApplicationManager.BuildWebsiteLink(null, campaign, Config.WebsiteFundraisingPage)); replacements.Add("[unsubscribe_url]", string.Format("mailto:{0}?subject=unsubscribe&body=Your%20stickers%20are%20great%20but%20please%20unsubscribe%20me.", Config.LeadMailboxLoginUID)); replacements.Add("[how_user_entered_info]", "to the \"Fundraising Ideas\" website"); // // Validate the row, all these fields must be there or we're wasting our time. // foreach (KeyValuePair <string, string> replacement in replacements) { if (!emailTemplate.Contains(replacement.Key)) { errMsg = string.Format("Cannot find required value in output file: \"{0}\"", replacement.Key); throw new ApplicationException(errMsg); // // Do something with the error here. // } else { emailTemplate = emailTemplate.Replace(replacement.Key, replacement.Value); } } MatchCollection leftovers1 = Regex.Matches(emailTemplate, "(\\[.*\\])"); if (leftovers1.Count > 0) { string msg = "You need to implement the following tokens:\r\n\r\n"; foreach (Match token in leftovers1) { msg = Functions.BuildStringFromElementsWithDelimiter(msg, token.Groups[0].ToString(), "\r\n"); } MessageBox.Show(msg, "Fix These", MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } string emailSubject = Functions.GetValueFromText(emailTemplate, "<title>(.*)</title>"); Functions.WriteStringAsFile(emailTemplate, outputEmailFile); Log("Done creating email, now gonna email it."); // Create a new email object Chilkat.Email email = new Chilkat.Email(); // Embed the images in the email - Outlook friendly. mht.UseCids = true; // Create an email from an HTML file. email = mht.GetEmail(outputEmailFile); if (email == null) { MessageBox.Show(mht.LastErrorText); return; } email.Subject = emailSubject; // email.Body = "This is a test"; email.From = string.Format("Fan Favorite Designs <{0}>", Config.LeadMailboxLoginUID); email.ReplyTo = Config.LeadMailboxLoginUID; if (debugging) { email.AddTo("Lead Monitor", "*****@*****.**"); } else { email.AddTo(lead.BuildFullName(), lead.EmailAddress); // email.AddBcc("Lead Monitor", "*****@*****.**"); } Chilkat.HtmlToText h2t = new Chilkat.HtmlToText(); // success = h2t.UnlockComponent(Config.ChilkatUnlockCodeEmail); success = h2t.UnlockComponent(ChilkatRegCodes.ChilkatHTMLtoXML); if (success != true) { MessageBox.Show(h2t.LastErrorText); return; } // Get the email's HTML body. string html; html = email.GetHtmlBody(); // Convert it to plain text: string plainText; plainText = h2t.ToText(html); // Add a few things so the email makes sense. plainText = string.Format("This email was meant to be viewed in HTML mode. You can visit \r\nour website here to get a better look at our product.\r\n\r\n {0}\r\n{1}", ApplicationManager.BuildWebsiteLink(null, campaign), plainText); // Add a plain-text alternative to the email: email.AddPlainTextAlternativeBody(plainText); // Call SendEmail to connect to the SMTP server and send. // The connection (i.e. session) to the SMTP server remains // open so that subsequent SendEmail calls may use the // same connection. Log("Sending SMTP mail..."); success = mailman.SendEmail(email); if (success != true) { sendRetries++; if (sendRetries < 5) { Log("Can't send email, gonna hang out for a bit, and try again."); Thread.Sleep(20000); } else { throw new ApplicationException("Cannot send email - cannot continue."); } } else if (!debugging && testLead == null) { // // Update the DB indicating that we sent the email so we don't do it again. // bool res = DataManager.AddLeadStatusLog(lead, Lead.LeadStatusCode.lscEmailSent, string.Format("lead-email-{0}.htm", _settings.EmailTemplateNo)); if (res) { Log("Updated status log - all good."); } else { Log("Yikes, can't update status log that we emailed! Bombing out."); throw new ApplicationException("Cannot update status log - cannot continue."); } sendRetries = 0; } else { Log("Email success; debug mode - not updating DB"); sendRetries = 0; } // Some SMTP servers do not actually send the email until // the connection is closed. In these cases, it is necessary to // call CloseSmtpConnection for the mail to be sent. // Most SMTP servers send the email immediately, and it is // not required to close the connection. We'll close it here // for the example: success = mailman.CloseSmtpConnection(); if (success != true) { Log("Connection to SMTP server not closed cleanly."); throw new ApplicationException("Cannot disconnect from SMTP server cleanly - cannot continue."); } } Log("Cleaning up temp files, if any."); string tempDirPath = Functions.BuildFilenameFromElements( _settings.EmailSrcDir, imagesSubdir, tempSubdir); string[] tempFiles = Directory.GetFiles(tempDirPath); foreach (string file in tempFiles) { File.Delete(file); } // todo: add icon to exe // todo: buy chilkat components Log("Processing of db leads completed"); }
public bool GetYahooMails(string yahooEmail, string yahooPassword) { GlobusHttpHelper HttpHelper = new GlobusHttpHelper(); bool activate = false; try { bool emaildata = false; Chilkat.Http http = new Chilkat.Http(); ///Chilkat Http Request to be used in Http Post... Chilkat.HttpRequest req = new Chilkat.HttpRequest(); bool success; // Any string unlocks the component for the 1st 30-days. success = http.UnlockComponent("THEBACHttp_b3C9o9QvZQ06"); if (success != true) { Console.WriteLine(http.LastErrorText); return(false); } http.CookieDir = "memory"; http.SendCookies = true; http.SaveCookies = true; //http.ProxyDomain = "127.0.0.1"; //http.ProxyPort = 8888; http.SetRequestHeader("Accept-Encoding", "gzip,deflate"); Chilkat.Imap iMap = new Imap(); string Username = yahooEmail; string Password = yahooPassword; //Username = "******"; //Password = "******"; iMap.UnlockComponent("THEBACIMAPMAILQ_OtWKOHoF1R0Q"); //iMap. //iMap.HttpProxyHostname = "127.0.0.1"; //iMap.HttpProxyPort = 8888; iMap.Connect("imap.n.mail.yahoo.com"); iMap.Login(yahooEmail, yahooPassword); iMap.SelectMailbox("Inbox"); // Get a message set containing all the message IDs // in the selected mailbox. Chilkat.MessageSet msgSet; //msgSet = iMap.Search("FROM \"facebookmail.com\"", true); msgSet = iMap.GetAllUids(); // Fetch all the mail into a bundle object. Chilkat.Email email = new Chilkat.Email(); //bundle = iMap.FetchBundle(msgSet); string strEmail = string.Empty; List <string> lstData = new List <string>(); if (msgSet != null) { for (int i = msgSet.Count; i > 0; i--) { email = iMap.FetchSingle(msgSet.GetId(i), true); strEmail = email.Subject; string emailHtml = email.GetHtmlBody(); lstData.Add(strEmail); if (email.Subject.Contains("[WordPress] Activate") && email.Subject.Contains("wordpress.com")) { foreach (string href in GetUrlsFromString(email.Body)) { try { string staticUrl = string.Empty; staticUrl = href; responce = http.QuickGetStr(staticUrl); if (responce.Contains("Your account is now active")) { emaildata = true; //Log("your Account is activate now"); activate = true; } } catch (Exception ex) { Console.WriteLine(ex.StackTrace); } } } } } if (emaildata == false) { Log("[ " + DateTime.Now + " ] => [ activation link is not find in user account so your Account is not activate please activate now ]"); } } catch (Exception ex) { } return(activate); }
public bool EmailVerification(string Email, string Password, ref GlobusHttpHelper globushttpHelper) { bool IsActivated = false; try { System.Windows.Forms.Application.DoEvents(); Chilkat.Http http = new Chilkat.Http(); if (Email.Contains("+")) { String[] emaildata = Email.Split('+'); Email = (emaildata[0] +"@" +emaildata[1].Split('@')[1]).Trim(); } if (Email.Contains("@yahoo")) { #region Yahoo Verification Steps GlobusHttpHelper HttpHelper = new GlobusHttpHelper(); bool activate = false; try { bool emaildata = false; //Chilkat.Http http = new Chilkat.Http(); ///Chilkat Http Request to be used in Http Post... Chilkat.HttpRequest req = new Chilkat.HttpRequest(); bool success; // Any string unlocks the component for the 1st 30-days. success = http.UnlockComponent("THEBACHttp_b3C9o9QvZQ06"); if (success != true) { Console.WriteLine(http.LastErrorText); return false; } http.CookieDir = "memory"; http.SendCookies = true; http.SaveCookies = true; //http.IPDomain = "127.0.0.1"; //http.IPPort = 8888; http.SetRequestHeader("Accept-Encoding", "gzip,deflate"); Chilkat.Imap iMap = new Imap(); string Username = Email; iMap.UnlockComponent("THEBACIMAPMAILQ_OtWKOHoF1R0Q"); //iMap. //iMap.HttpIPHostname = "127.0.0.1"; //iMap.HttpIPPort = 8888; iMap.Port = 993; iMap.Connect("imap.n.mail.yahoo.com"); iMap.Login(Email, Password); iMap.SelectMailbox("Inbox"); // Get a message set containing all the message IDs // in the selected mailbox. Chilkat.MessageSet msgSet; //msgSet = iMap.Search("FROM \"facebookmail.com\"", true); msgSet = iMap.GetAllUids(); if (msgSet.Count <= 0) { msgSet = iMap.GetAllUids(); } // Fetch all the mail into a bundle object. Chilkat.Email email = new Chilkat.Email(); //bundle = iMap.FetchBundle(msgSet); string strEmail = string.Empty; List<string> lstData = new List<string>(); if (msgSet != null) { for (int i = msgSet.Count; i > 0; i--) //for (int i = 0; i < msgSet.Count; i++) { try { email = iMap.FetchSingle(msgSet.GetId(i), true); strEmail = email.Subject; string emailHtml = email.GetHtmlBody(); lstData.Add(strEmail); string from = email.From.ToString().ToLower(); if (from.Contains("twitter.com") || from.Contains("account-verification")) { #region <old User Parser //foreach (string href in GetUrlsFromString(email.Body)) //{ // try // { // if (href.Contains("https://twitter.com/account/confirm_email/") ) // { // string ConfirmationResponse = globushttpHelper.getHtmlfromUrl(new Uri(href), "", ""); // IsActivated = true; // } // } // catch (Exception ex) // { // Console.WriteLine("6 :" + ex.StackTrace); // } //} #endregion string[] arr = Regex.Split(email.Body, "href"); foreach (string strhref in arr) { if (!strhref.Contains("<!DOCTYPE")) { if (strhref.Contains("https://twitter.com/account/confirm_email")) { string AncherTag = System.Text.RegularExpressions.Regex.Split(strhref, ">")[1]; string tempString = AncherTag.Substring(AncherTag.IndexOf("https")); string DataUrl = tempString.Replace("<>", "").Replace(">", string.Empty).Replace("\r", string.Empty).Replace("\n", string.Empty).Replace("</a", string.Empty); string ConfirmationResponse = globushttpHelper.getHtmlfromUrl(new Uri(DataUrl), "", ""); IsActivated = true; break; } } } } if (IsActivated) { Log("[ " + DateTime.Now + " ] => [ Account : " + Email + " verified ]"); break; } } catch { }; } } } catch (Exception ex) { Console.WriteLine("7 :" + ex.StackTrace); Log("[ " + DateTime.Now + " ] => [ Email Verification Exception : " + ex.Message + " with : " + Email + " ]"); } return IsActivated; #endregion } else { string Host = string.Empty; int Port = 0; if (Email.Contains("@gmail")) { Host = "pop.gmail.com"; Port = 995; } else if (Email.Contains("@hotmail")) { Host = "pop3.live.com"; Port = 995; } else if (Email.Contains("@gmx")) { Host = "pop.gmx.com"; Port = 995; } if (!string.IsNullOrEmpty(Host)) { if (popClient.Connected) popClient.Disconnect(); popClient.Connect(Host, Port, true); popClient.Authenticate(Email, Password); int Count = popClient.GetMessageCount(); for (int i = Count; i >= 1; i--) { try { OpenPOP.MIME.Message Message = popClient.GetMessage(i); string subject = string.Empty; subject = Message.Headers.Subject; bool GoIntoEmail = false; if (string.IsNullOrEmpty(subject)) { string from = Message.Headers.From.ToString().ToLower(); if (from.Contains("twitter.com")) { GoIntoEmail = true; } } try { if (GoIntoEmail || subject.Contains("Twitter")) //if(GoIntoEmail) { string Messagebody = Message.MessageBody[0]; foreach (string href in GetUrlsFromStringGmail(Messagebody)) { try { if (href.Contains("https://twitter.com/account/confirm_email/")) { string ConfirmationResponse = globushttpHelper.getHtmlfromUrl(new Uri(href), "", ""); IsActivated = true; break; } } catch (Exception ex) { Console.WriteLine("5 :" + ex.StackTrace); }; } } } catch (Exception ex) { Console.WriteLine("10 :" + ex.StackTrace); Log("[ " + DateTime.Now + " ] => [ Email Verification Exception : " + ex.Message + " with : " + Email + " ]"); } if (IsActivated) { break; } } catch (Exception ex) { Log("[ " + DateTime.Now + " ] => [ Email Verification Exception : " + ex.Message + " with : " + Email + " ]"); } } } } return IsActivated; } catch (Exception ex) { Console.WriteLine("4 :" + ex.StackTrace); return IsActivated; } }