static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Console.Write("program Started ...."); //string user = Console.ReadLine(); //string Password = Console.ReadLine(); string user = "******"; string Password = "******"; Console.Clear(); EmailBankCore EB = new EmailBankCore(user, Password); if (!EB.Status) { Application.Exit(); Console.WriteLine("Faild To login Please Restart Program And Enter A USername Or Password Carefuly"); Console.Read(); } else { Console.WriteLine("Email Sending......"); Console.Read(); } }
public bool GmailSender(string From, string To, string Subject, string Body, bool IsBodyHTML) { try { MailMessage mail = new MailMessage(); mail.From = new MailAddress(From); mail.To.Add(To); mail.Subject = Subject; mail.Body = Body; mail.IsBodyHtml = IsBodyHTML; SmtpClient smtp = new SmtpClient(From, 587); smtp.UseDefaultCredentials = false; smtp.EnableSsl = true; smtp.Credentials = new NetworkCredential(UserName, Password); //smtp.Credentials = new NetworkCredential("*****@*****.**", "m8211106756"); smtp.Timeout = 3000; smtp.Send(mail); smtp.Dispose(); return(true); } catch (Exception Ex) { EmailBankCore.LogRegister("GmailSender", Ex.Message); //System.Diagnostics.EventLog.WriteEntry(To, Ex.ToString()); return(false); } }
public bool EmailSender(string From, string To, string Subject, string Body, bool IsBodyHTML, int RepeatCount, ref string ErrorMessage) { int c = RepeatCount + 1; SMTPProperty smtpprop = new SMTPProperty(); try { if (RepeatCount <= 3) { smtpprop = GetActiveSmtpClient(); MailMessage mail = new MailMessage(); mail.From = new MailAddress(From); mail.To.Add(To); mail.Subject = Subject; mail.Body = Body; mail.IsBodyHtml = IsBodyHTML; smtpprop.ISbusy = true; smtpprop.SMTP.Send(mail); smtpprop.ISbusy = false; ErrorMessage = ""; return(true); //SmtpClient smtp = new SmtpClient(SMTPserverAddress, Port); //smtp.Timeout = 1000000; //smtp.EnableSsl = false; //smtp.UseDefaultCredentials = false; //smtp.Credentials = new NetworkCredential(CridentionalUserName, Password); //MailMessage mail = new MailMessage(); //mail.From = new MailAddress(From); //mail.To.Add(To); //mail.Subject = Subject; //mail.Body = Body; //mail.IsBodyHtml = IsBodyHTML; //smtp.Send(mail); //ErrorMessage = ""; //smtp.Dispose(); //return true; } else { return(false); } } catch (Exception Ex) { EmailBankCore.LogRegister("EmailSender To : " + To, Ex.Message); //smtpprop.ISbusy = false; ErrorMessage = Ex.Message; System.Threading.Thread.Sleep(1000); bool bl = EmailSender(From, To, Subject, Body, IsBodyHTML, c, ref ErrorMessage); return(bl); } }
public SmtpClient GetNewSMTP() { try { SmtpClient smtp = new SmtpClient(SMTPserverAddress, Port); smtp.Timeout = 1000000; smtp.EnableSsl = false; smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential(CridentionalUserName, Password); return(smtp); } catch (Exception ex) { EmailBankCore.LogRegister("GetNewSMTP", ex.Message); SmtpClient smtp = new SmtpClient(SMTPserverAddress, Port); smtp.Timeout = 1000000; smtp.EnableSsl = false; smtp.UseDefaultCredentials = false; smtp.Credentials = new NetworkCredential(CridentionalUserName, Password); return(smtp); } }
void EmailReciveChecker(object State) { try { Console.WriteLine("emailCheckOn : " + EmailBankCore.ClockServer()); TestForm.messageBody[] eBankMessage = new TestForm.messageBody[TestForm.messageBodyList.Count]; TestForm.messageBodyList.CopyTo(eBankMessage); if (!TestForm.EmailReciveCheckerISbusy && !TestForm.EmailAddCheckerISbusy) { TestForm.EmailReciveCheckerISbusy = true; foreach (TestForm.messageBody MessageRecived in eBankMessage) { Console.WriteLine("New Message Recived From : " + MessageRecived.MailSender); EmailsenderClass mail = new EmailsenderClass(); mail.UserName = "******"[email protected]\"<" + ConfigurationManager.AppSettings["EmailAddress"].ToString() + ">"; mail.Password = ConfigurationManager.AppSettings["EmailPassword"].ToString(); //______________________________________________________________________________ long CustomerID = CustomerIDMining(MessageRecived.DepositeNubmer); if (CustomerID == 0) { PageCreator PC = new PageCreator(); //"*****@*****.**" string Page = PC.PageBuilder(); MailInformation Mailinfo = new MailInformation { CustomerEmailAddress = MessageRecived.MailSender, CustomerID = CustomerID, EmailText = Page, MailProperties = mail, Subject = "Error", EmailType = "2", DepositeNumber = MessageRecived.DepositeNubmer }; CreateEmailThread(Mailinfo); } else { SBS.DataModel.CustomerModel CustomerInfo; int ii = 0; while (true) { try { CustomerInfo = iCustomer.SelectOneWithOutDeepLoad(CustomerID); break; } catch (Exception ex) { ii++; if (ii > 10) { return; } if (Login(UserName, PassWord)) { iCustomer = SBS.CommonUtils.FacadeFactory.CustomerManager("", LoggedInUserInfo.UserIdentity.ToString(), (short)SBS.CommonUtils.ConstantData.AppUC.Email_SubSystem, LoggedInUserInfo.TicketStr); iWithdrawals = SBS.CommonUtils.FacadeFactory.WithdrawalsSettlementManager("", LoggedInUserInfo.UserIdentity.ToString(), (short)SBS.CommonUtils.ConstantData.AppUC.Email_SubSystem, LoggedInUserInfo.TicketStr); } } } //CustomerInfo.Email = "*****@*****.**"; //CustomerInfo.Email = "*****@*****.**"; //CustomerInfo.Email = "*****@*****.**"; //______________________________________________________________________________ if (!string.IsNullOrEmpty(CustomerInfo.Email)) { PageCreator PC = new PageCreator(); //"*****@*****.**" UserInformation UserInf = new UserInformation { PreName = "", Name = CustomerInfo.DisplayName, ActionType = "گردش سپرده", DepositNubmer = MessageRecived.DepositeNubmer, Amount = CustomerInfo.Amount.ToString(), Comment = CustomerInfo.Comment, Date = FarsiDateServer(), RemainAmount = CustomerInfo.RemainAmount.ToString(), Time = ClockServer(), IsTransaction = false, }; if (MessageRecived.TransactionCountRequested <= 200) { UserInf.TransactionCountRequested = MessageRecived.TransactionCountRequested; } else { UserInf.TransactionCountRequested = 200; } if (MessageRecived.Blocked) { string Page = PC.PageBuilder(UserInf); MailInformation Mailinfo = new MailInformation { CustomerEmailAddress = CustomerInfo.Email, CustomerID = CustomerID, EmailText = Page, MailProperties = mail, Subject = "بیش از حد مجاز", EmailType = "2", DepositeNumber = MessageRecived.DepositeNubmer }; CreateEmailThread(Mailinfo); } else { List <ReportDetails> LRep = ReportDetailsBuilder(MessageRecived.DepositeNubmer, MessageRecived.TransactionCountRequested); UserInf.RealTransactionCount = short.Parse(LRep.Count.ToString()); string Page = PC.PageBuilder(UserInf, LRep); MailInformation Mailinfo = new MailInformation { CustomerEmailAddress = CustomerInfo.Email, CustomerID = CustomerID, EmailText = Page, MailProperties = mail, Subject = "گردش سپرده", EmailType = "2", DepositeNumber = MessageRecived.DepositeNubmer }; CreateEmailThread(Mailinfo); } } } while (true) { if (!TestForm.EmailAddCheckerISbusy) { TestForm.EmailAddCheckerISbusy = true; TestForm.messageBodyList.Remove(MessageRecived); TestForm.EmailAddCheckerISbusy = false; break; } } } TestForm.EmailReciveCheckerISbusy = false; } } catch (Exception ex) { LogRegister("EmailReciveChecker", ex.Message); } }
public SMTPProperty GetActiveSmtpClient() { try { if (SMTPList.Count <= 0) { SmtpClient smtp = GetNewSMTP(); SMTPProperty smtpp = new SMTPProperty { SMTP = smtp, ISbusy = false, TTL = Environment.TickCount }; SMTPList.Add(smtpp); return(SMTPList[SMTPList.Count - 1]); } else { int i = 0; while (SMTPList[i].ISbusy) { i++; if (i >= SMTPList.Count) { if (i <= 50) { SmtpClient smtp = GetNewSMTP(); SMTPProperty smtpp = new SMTPProperty { SMTP = smtp, ISbusy = false, TTL = Environment.TickCount }; SMTPList.Add(smtpp); return(SMTPList[SMTPList.Count - 1]); } else { System.Threading.Thread.Sleep(1000); return(GetActiveSmtpClient()); } } } long Tick = Environment.TickCount; if ((-SMTPList[i].TTL) > 1000000) { SmtpClient smtp = GetNewSMTP(); SMTPProperty smtpp = new SMTPProperty { SMTP = smtp, ISbusy = false, TTL = Environment.TickCount }; SMTPList[i] = smtpp; } return(SMTPList[i]); } } catch (Exception ex) { EmailBankCore.LogRegister("GetActiveSmtpClient", ex.Message); SmtpClient smtp = new SmtpClient(SMTPserverAddress, Port); smtp.UseDefaultCredentials = false; smtp.EnableSsl = false; smtp.Credentials = new NetworkCredential(CridentionalUserName, Password); SMTPProperty smtpp = new SMTPProperty { SMTP = smtp, ISbusy = false, TTL = Environment.TickCount }; return(smtpp); } }