public virtual CloudAccountDA.SMTPSettingsDataTable GetData() { this.Adapter.SelectCommand = this.CommandCollection[0]; CloudAccountDA.SMTPSettingsDataTable dataTable = new CloudAccountDA.SMTPSettingsDataTable(); this.Adapter.Fill(dataTable); return(dataTable); }
private void SetData(string companyID) { this.objCompanyMasterDT = this.objCompanyMasterBll.GetDataByCompanyID(int.Parse(companyID)); if (this.objCompanyMasterDT.Rows.Count > 0) { this.lblCompanyName.Text = this.objCompanyMasterDT.Rows[0]["CompanyName"].ToString(); this.lblEmail.Text = this.objCompanyMasterDT.Rows[0]["CompanyEmail"].ToString(); } this.objSMTPSettingsDT = this.objSMTPSettingsBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); if (this.objSMTPSettingsDT.Rows.Count > 0) { this.txtEmailSignature.Text = this.objSMTPSettingsDT.Rows[0]["EmailSignature"].ToString(); this.txtEmailSignature.Text = this.txtEmailSignature.Text.Replace("<br />", "\n"); this.txtEmailSignature.Text = this.txtEmailSignature.Text.Replace("##companyName##", this.lblCompanyName.Text); this.txtEmailSignature.Text = this.txtEmailSignature.Text.Replace("##companyEmail##", this.lblEmail.Text); this.txtHost.Text = this.objSMTPSettingsDT.Rows[0]["Host"].ToString(); this.txtSMTPFrom.Text = this.objSMTPSettingsDT.Rows[0]["SMTPFrom"].ToString(); this.txtPort.Text = this.objSMTPSettingsDT.Rows[0]["Port"].ToString(); this.txtPassword.Text = this.objSMTPSettingsDT.Rows[0]["Password"].ToString(); this.txtUsername.Text = this.objSMTPSettingsDT.Rows[0]["Username"].ToString(); this.chkEnableSSL.Checked = bool.Parse(this.objSMTPSettingsDT.Rows[0]["EnableSSL"].ToString()); this.txtPassword.Attributes["type"] = "password"; } else { this.objSMTPSettingsBll.AddSMTPSettings(int.Parse(this.hfCompanyID.Value), "*****@*****.**", "mail.billtransact.com", new int?(25), false, "bayaka20@25", "*****@*****.**", "Best regards,<br />##companyName## (##companyEmail##)"); this.Response.Redirect("SMTPSettings.aspx"); } }
public virtual int Fill(CloudAccountDA.SMTPSettingsDataTable dataTable) { this.Adapter.SelectCommand = this.CommandCollection[0]; if (this.ClearBeforeFill) { dataTable.Clear(); } return(this.Adapter.Fill(dataTable)); }
private void SendMail(string user, string pass, string email) { this.objCompanyMasterDT = this.objCompanyMasterBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); string str = this.objCompanyMasterDT.Rows[0]["CompanyName"].ToString(); string addresses = this.objCompanyMasterDT.Rows[0]["CompanyEmail"].ToString(); Hashtable Variables = new Hashtable() { { (object)"company", (object)str }, { (object)"companyEmail", (object)addresses }, { (object)"username", (object)user }, { (object)"password", (object)pass } }; string address = "*****@*****.**"; this.objSMTPSettingsDT = this.objSMTPSettingsBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); if (this.objSMTPSettingsDT.Rows.Count > 0) { address = this.objSMTPSettingsDT.Rows[0]["SMTPFrom"].ToString(); } Parser parser = new Parser(this.Server.MapPath("~/MailTemplate/CompanyClient.htm"), Variables); try { MailMessage message = new MailMessage() { From = new MailAddress(address, str.ToUpper()) }; message.To.Add(new MailAddress(email)); message.ReplyToList.Add(addresses); message.Subject = str.ToUpper() + " is now invoicing you with Bill Transact"; message.BodyEncoding = Encoding.UTF8; message.Body = parser.Parse(); message.IsBodyHtml = true; SmtpClientForCompany.smtpClient(this.hfCompanyID.Value).Send(message); } catch (Exception ex) { this.DisplayAlert("Error in sending mail." + (object)ex); } }
public virtual CloudAccountDA.SMTPSettingsDataTable DeleteByCompanyID(int?CompanyID) { this.Adapter.SelectCommand = this.CommandCollection[1]; if (CompanyID.HasValue) { this.Adapter.SelectCommand.Parameters[1].Value = CompanyID.Value; } else { this.Adapter.SelectCommand.Parameters[1].Value = DBNull.Value; } CloudAccountDA.SMTPSettingsDataTable dataTable = new CloudAccountDA.SMTPSettingsDataTable(); this.Adapter.Fill(dataTable); return(dataTable); }
protected void btnSave_Click(object sender, EventArgs e) { if (!this.Page.IsValid) { return; } this.btnCheck_Click(sender, e); if (string.IsNullOrEmpty(this.lblError.Text) || !(this.lblError.ForeColor == Color.Green)) { return; } int num = 0; bool flag = false; this.objSMTPSettingsDT = this.objSMTPSettingsBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); if (this.objSMTPSettingsDT.Rows.Count > 0) { string s = this.objSMTPSettingsDT.Rows[0]["SMTPSettingsID"].ToString(); int? iPort = new int?(); if (this.txtPort.Text.Trim().Length > 0) { iPort = new int?(int.Parse(this.txtPort.Text)); } this.txtEmailSignature.Text = this.txtEmailSignature.Text.Replace("\n", "<br />"); this.txtEmailSignature.Text = this.txtEmailSignature.Text.Replace(this.lblCompanyName.Text, "##companyName##"); this.txtEmailSignature.Text = this.txtEmailSignature.Text.Replace(this.lblEmail.Text, "##companyEmail##"); flag = this.objSMTPSettingsBll.UpdateSMTPSettings(int.Parse(s), int.Parse(this.hfCompanyID.Value), this.txtSMTPFrom.Text, this.txtHost.Text.Trim(), iPort, this.chkEnableSSL.Checked, this.txtPassword.Text, this.txtUsername.Text, this.txtEmailSignature.Text); } else { int?iPort = new int?(); if (this.txtPort.Text.Trim().Length > 0) { iPort = new int?(int.Parse(this.txtPort.Text)); } this.txtEmailSignature.Text = this.txtEmailSignature.Text.Replace("\n", "<br />"); this.txtEmailSignature.Text = this.txtEmailSignature.Text.Replace(this.lblCompanyName.Text, "##companyName##"); this.txtEmailSignature.Text = this.txtEmailSignature.Text.Replace(this.lblEmail.Text, "##companyEmail##"); num = this.objSMTPSettingsBll.AddSMTPSettings(int.Parse(this.hfCompanyID.Value), this.txtSMTPFrom.Text, this.txtHost.Text.Trim(), iPort, this.chkEnableSSL.Checked, this.txtPassword.Text, this.txtUsername.Text, this.txtEmailSignature.Text); } if (num == 0 && !flag) { return; } this.Response.Redirect("SMTPSettings.aspx"); }
private void SendMail(string email, string invoiceNum, int invoiceId, int clientId, int companyID) { this.objInvoiceMasterDT = this.objInvoiceMasterBll.GetDataByInvoiceID(invoiceId); string str1 = this.objInvoiceMasterDT.Rows[0]["InvoiceNumber"].ToString(); string s1 = this.objInvoiceMasterDT.Rows[0]["InvoiceTotal"].ToString(); string s2 = this.objInvoiceMasterDT.Rows[0]["PaidToDate"].ToString(); Decimal num = Decimal.Parse(s1) - Decimal.Parse(s2); this.objCompanyMasterDT = this.objCompanyMasterBll.GetDataByCompanyID(companyID); string displayName = this.objCompanyMasterDT.Rows[0]["CompanyName"].ToString().ToUpper(); string addresses = this.objCompanyMasterDT.Rows[0]["CompanyEmail"].ToString(); string str2 = string.Empty; string str3 = string.Empty; string str4 = string.Empty; string str5 = string.Empty; this.objCompanyClientMasterDT = this.objCompanyClientMasterBll.GetDataByCompanyClientID(clientId); if (this.objCompanyClientMasterDT.Rows.Count > 0) { string username = this.objCompanyClientMasterDT.Rows[0]["UserName"].ToString(); str3 = this.objCompanyClientMasterDT.Rows[0]["OrganizationName"].ToString(); str4 = this.objCompanyClientMasterDT.Rows[0]["FirstName"].ToString(); str5 = this.objCompanyClientMasterDT.Rows[0]["LastName"].ToString(); email = this.objCompanyClientMasterDT.Rows[0]["Email"].ToString(); MembershipUser user = Membership.GetUser(username); if (user != null) { string key1 = MemberArea.GenerateCode(); string str6 = HttpUtility.UrlEncode(this.Encrypt(user.UserName, key1)); string password = user.GetPassword(); string key2 = MemberArea.GenerateCode(); string str7 = HttpUtility.UrlEncode(this.Encrypt(password, key2)); str2 = string.Format("https://www.billtransact.com/CheckClient.aspx?page=invoice&anyId={0}&name={1}&tech={2}&keyname={3}&keytech={4}", (object)invoiceId, (object)str6, (object)str7, (object)key1, (object)key2); } } string str8 = string.Empty; string str9 = string.Empty; string address = "*****@*****.**"; this.objSMTPSettingsDT = this.objSMTPSettingsBll.GetDataByCompanyID(companyID); if (this.objSMTPSettingsDT.Rows.Count > 0) { str9 = this.objSMTPSettingsDT.Rows[0]["EmailSignature"].ToString(); address = this.objSMTPSettingsDT.Rows[0]["SMTPFrom"].ToString(); } this.objNewInvoiceEmailTemplateDT = this.objNewInvoiceEmailTemplateBll.GetDataByCompanyID(companyID); if (this.objNewInvoiceEmailTemplateDT.Rows.Count > 0) { str8 = this.objNewInvoiceEmailTemplateDT.Rows[0]["EmailBody"].ToString(); } Hashtable Variables = new Hashtable() { { (object)"emailTemplate", (object)str8 }, { (object)"companyName", (object)displayName }, { (object)"companyEmail", (object)("<a href=\"mailto:" + addresses + "\">" + addresses + "</a>") }, { (object)"invoiceNumber", (object)str1 }, { (object)"amountOwned", (object)num }, { (object)"clientOrgName", (object)str3 }, { (object)"firstName", (object)str4 }, { (object)"lastName", (object)str5 }, { (object)"invoiceAmt", (object)s1 }, { (object)"someLink", (object)str2 }, { (object)"directLink", (object)"block" }, { (object)"branding", (object)"block" }, { (object)"emailSign", (object)str9 } }; Parser parser1 = new Parser(this.Server.MapPath("~/MailTemplate/SendInvoiceNew.html"), Variables); string path1 = this.Server.MapPath("~\\TempHTMLFiles\\"); File.WriteAllText(Path.Combine(path1, "Invoice.html"), parser1.Parse()); Parser parser2 = new Parser(path1 + "Invoice.html", Variables); try { MailMessage message = new MailMessage() { From = new MailAddress(address, displayName) }; message.To.Add(new MailAddress(email)); message.ReplyToList.Add(addresses); message.Subject = "New invoice " + invoiceNum + " from " + displayName + ", sent using Bill Transact"; message.BodyEncoding = Encoding.UTF8; message.Body = parser2.Parse(); message.IsBodyHtml = true; SmtpClientForCompany.smtpClient(companyID.ToString()).Send(message); } catch (Exception ex) { } }
public virtual int Update(CloudAccountDA.SMTPSettingsDataTable dataTable) { return(this.Adapter.Update(dataTable)); }
private void SetNewDefaultValues() { MembershipUser user = Membership.GetUser(); if (user != null) { string str = user.ToString(); if (Roles.IsUserInRole(str, "Admin")) { this.objCompanyLoginMasterDT = this.objCompanyLoginMasterBll.GetDataByCompanyLoginName(str); if (this.objCompanyLoginMasterDT.Rows.Count > 0) { this.hfCompanyID.Value = this.objCompanyLoginMasterDT.Rows[0]["CompanyID"].ToString(); } } else if (Roles.IsUserInRole(str, "Employee")) { this.objStaffMasterDT = this.objStaffMasterBll.GetDataByStaffUserName(str); if (this.objStaffMasterDT.Rows.Count > 0) { this.hfCompanyID.Value = this.objStaffMasterDT.Rows[0]["CompanyID"].ToString(); } } } int num = 30; this.objFreePackageSettingsDT = this.objFreePackageSettingsBll.GetAllDetail(); if (this.objFreePackageSettingsDT.Rows.Count > 0) { num = int.Parse(this.objFreePackageSettingsDT.Rows[0]["FreePackageDays"].ToString()); } this.objCompanyPackageMasterDT = this.objCompanyPackageMasterBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); if (this.objCompanyPackageMasterDT.Rows.Count == 0) { this.objCompanyPackageMasterBll.AddCompanyPackage(int.Parse(this.hfCompanyID.Value), 0, new DateTime?(DateTime.Now), new DateTime?(DateTime.Now.AddDays((double)num)), "FREE", new Decimal?(new Decimal(0)), "NONE", new DateTime?(), new DateTime?(DateTime.Now), true); } this.objAdminPermissionMasterDT = this.objAdminPermissionMasterBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); if (this.objAdminPermissionMasterDT.Rows.Count == 0) { this.objAdminPermissionMasterBll.AddAdminPermission(int.Parse(this.hfCompanyID.Value), true, true, true, false, false); } this.objMiscellaneousMasterDT = this.objMiscellaneousMasterBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); if (this.objMiscellaneousMasterDT.Rows.Count == 0) { this.objMiscellaneousMasterBll.AddMiscellaneous(int.Parse(this.hfCompanyID.Value), 15, "MM/dd/yyyy", true, true, true, "", true, false, "Both", "", "", "None", "Read/Write", 30, 10); } this.objClientPermissionMasterDT = this.objClientPermissionMasterBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); if (this.objClientPermissionMasterDT.Rows.Count == 0) { this.objClientPermissionMasterBll.AddClientPermission(int.Parse(this.hfCompanyID.Value), true, true, true, false, false, true, true); } this.objStaffPermissionMasterDT = this.objStaffPermissionMasterBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); if (this.objStaffPermissionMasterDT.Rows.Count == 0) { this.objStaffPermissionMasterBll.AddStaffPermission(int.Parse(this.hfCompanyID.Value), true, true, true, true, true, false, false, true, true, true, true, true); } this.objTemplateSettingsDT = this.objTemplateSettingsBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); if (this.objTemplateSettingsDT.Rows.Count == 0) { this.objTemplateSettingsBll.AddTemplateSettings(int.Parse(this.hfCompanyID.Value), 1, "Invoice", "Estimate", "Credit", true); } this.objEmailNotificationsDT = this.objEmailNotificationsBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); if (this.objEmailNotificationsDT.Rows.Count == 0) { this.objEmailNotificationsBll.AddEmailNotifications(int.Parse(this.hfCompanyID.Value), true, false, false, false); } this.objSMTPSettingsDT = this.objSMTPSettingsBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); if (this.objSMTPSettingsDT.Rows.Count == 0) { this.objSMTPSettingsBll.AddSMTPSettings(int.Parse(this.hfCompanyID.Value), Common.CommonHandler.BaseMailFrom, Common.CommonHandler.BaseHost, Convert.ToInt32(Common.CommonHandler.BasePort), Common.CommonHandler.BaseEnableSSL, Common.CommonHandler.BasePassword, Common.CommonHandler.BaseUserName, "Best regards,<br />##companyName## (##companyEmail##)"); } this.objNewClientEmailTemplateDT = this.objNewClientEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); if (this.objNewClientEmailTemplateDT.Rows.Count == 0) { this.objNewClientEmailTemplateBll.AddClientTemplate(int.Parse(this.hfCompanyID.Value), "##companyName## is now invoicing you with Bill Transact", new StringBuilder("Welcome to ##companyName##'s secure online services. An account has been created for you.<br />To securely access your account, go to:<br />##login link##<br />Login using the following username and password:<br />Username: ##username##<br />Password: ##password##<br />").ToString()); } this.objNewCreditEmailTemplateDT = this.objNewCreditEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); if (this.objNewCreditEmailTemplateDT.Rows.Count == 0) { this.objNewCreditEmailTemplateBll.AddCreditTemplate(int.Parse(this.hfCompanyID.Value), "New Credit ##creditNumber## from ##companyName## , sent using Bill Transact", new StringBuilder("You have received credit in the amount of ##paymentAmt##. To view it and download a PDF copy for your records, click the link below.<br /><br />##creditLink##<br />").ToString()); } this.objNewEstimateEmailTemplateDT = this.objNewEstimateEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); if (this.objNewEstimateEmailTemplateDT.Rows.Count == 0) { this.objNewEstimateEmailTemplateBll.AddEstimateTemplate(int.Parse(this.hfCompanyID.Value), "New Estimate ##estimateNumber## from ##companyName## , sent using Bill Transact", new StringBuilder("To access your estimate from ##companyName## for ##paymentAmt##, go to:<br /><br /> ##estimateLink##<br />").ToString()); } this.objNewInvoiceEmailTemplateDT = this.objNewInvoiceEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); if (this.objNewInvoiceEmailTemplateDT.Rows.Count == 0) { this.objNewInvoiceEmailTemplateBll.AddInvoiceTemplate(int.Parse(this.hfCompanyID.Value), "New invoice ##invoiceNumber## from ##companyName## , sent using Bill Transact", new StringBuilder("To view your invoice from ##companyName## for ##invoiceAmt##, or to download a PDF copy for your records, click the link below:<br /><br />##someLink##<br /><br />").ToString()); } this.objNewStaffEmailTemplateDT = this.objNewStaffEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); if (this.objNewStaffEmailTemplateDT.Rows.Count == 0) { this.objNewStaffEmailTemplateBll.AddStaffTemplate(int.Parse(this.hfCompanyID.Value), "##companyName## invites you to track time and expenses in Bill Transact", new StringBuilder("You are now part of ##companyName##'s team.<br />Click here to log in to your account:<br />##login link##<br /><br />Username: ##username##<br />Password: ##password##<br />").ToString()); } this.objNewPaymentEmailTemplateDT = this.objNewPaymentEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), "online"); if (this.objNewPaymentEmailTemplateDT.Rows.Count == 0) { this.objNewPaymentEmailTemplateBll.AddPaymentTemplate(int.Parse(this.hfCompanyID.Value), "online", true, "##companyName## has received your payment for invoice ##invoiceNumber## in Bill Transact", new StringBuilder("Thank you for your business.<br />We have received your payment in the amount of ##payment amount## for invoice ##invoice number##.<br />To view the paid invoice or download a PDF copy for your records, click the link below:<br /><br />##someLink##<br />").ToString()); } this.objNewPaymentEmailTemplateDT = this.objNewPaymentEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), "other"); if (this.objNewPaymentEmailTemplateDT.Rows.Count == 0) { this.objNewPaymentEmailTemplateBll.AddPaymentTemplate(int.Parse(this.hfCompanyID.Value), "other", false, "##companyName## has received your payment for invoice ##invoiceNumber## in Bill Transact", new StringBuilder("Thank you for your business.<br />We have received your payment in the amount of ##payment amount## for invoice ##invoice number##.<br />To view the paid invoice or download a PDF copy for your records, click the link below:<br /><br />##someLink##<br />").ToString()); } this.objLatePaymentReminderTemplateDT = this.objLatePaymentReminderTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), 1); if (this.objLatePaymentReminderTemplateDT.Rows.Count == 0) { this.objLatePaymentReminderTemplateBll.AddLatePaymentReminder(int.Parse(this.hfCompanyID.Value), 1, false, 30, "Your payment for invoice ##invoiceNumber## is overdue in Bill Transact", new StringBuilder("Your invoice is now 30 days overdue. Please pay your invoice.<br /><br />To access your invoice from ##companyName##, go to:<br /><br />##someLink##<br />").ToString()); } this.objLatePaymentReminderTemplateDT = this.objLatePaymentReminderTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), 2); if (this.objLatePaymentReminderTemplateDT.Rows.Count == 0) { this.objLatePaymentReminderTemplateBll.AddLatePaymentReminder(int.Parse(this.hfCompanyID.Value), 2, false, 60, "Your payment for invoice ##invoiceNumber## is overdue in Bill Transact", new StringBuilder("Your invoice is now 60 days overdue. Please pay your invoice.<br /><br />To access your invoice from ##companyName##, go to:<br /><br />##someLink##<br />").ToString()); } this.objLatePaymentReminderTemplateDT = this.objLatePaymentReminderTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), 3); if (this.objLatePaymentReminderTemplateDT.Rows.Count == 0) { this.objLatePaymentReminderTemplateBll.AddLatePaymentReminder(int.Parse(this.hfCompanyID.Value), 3, false, 90, "Your payment for invoice ##invoiceNumber## is overdue in Bill Transact", new StringBuilder("Your invoice is now 90 days overdue. Please pay your invoice.<br /><br />To access your invoice from ##companyName##, go to:<br /><br />##someLink##<br />").ToString()); } this.objAutoBillEmailTemplateDT = this.objAutoBillEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), "Auto-bill"); if (this.objAutoBillEmailTemplateDT.Rows.Count == 0) { this.objAutoBillEmailTemplateBll.AddAutoBillEmail(int.Parse(this.hfCompanyID.Value), "Auto-bill", true, "New recurring invoice ##invoiceNumber## from ##companyName##, sent using Bill Transact", this.strBodyBill.ToString()); } this.objAutoBillEmailTemplateDT = this.objAutoBillEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), "Auto-paid"); if (this.objAutoBillEmailTemplateDT.Rows.Count == 0) { this.objAutoBillEmailTemplateBll.AddAutoBillEmail(int.Parse(this.hfCompanyID.Value), "Auto-paid", true, "New recurring invoice ##invoiceNumber## from ##companyName##, sent using Bill Transact", this.strBodyPaid.ToString()); } this.objAutoBillEmailTemplateDT = this.objAutoBillEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), "Card Expired"); if (this.objAutoBillEmailTemplateDT.Rows.Count == 0) { this.objAutoBillEmailTemplateBll.AddAutoBillEmail(int.Parse(this.hfCompanyID.Value), "Card Expired", true, "Action required: Your credit card on file with ##companyName## is expiring soon in Bill Transact", this.strBodyExpired.ToString()); } this.objAutoBillEmailTemplateDT = this.objAutoBillEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), "Card Failed"); if (this.objAutoBillEmailTemplateDT.Rows.Count != 0) { return; } this.objAutoBillEmailTemplateBll.AddAutoBillEmail(int.Parse(this.hfCompanyID.Value), "Card Failed", false, "Action required: Your credit card on file for invoice ##invoiceNumber## from ##companyName## needs updating in Bill Transact", this.strBodyFailed.ToString()); }
private async Task SendMailNew(int paymentID) { this.objCompanyMasterDT = this.objCompanyMasterBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); string displayName = this.objCompanyMasterDT.Rows[0]["CompanyName"].ToString().ToUpper(); string addresses = this.objCompanyMasterDT.Rows[0]["CompanyEmail"].ToString(); this.objPaymentMasterDT = this.objPaymentMasterBll.GetDataByPaymentID(paymentID); string s1 = this.objPaymentMasterDT.Rows[0]["InvoiceID"].ToString(); this.objInvoiceMasterDT = this.objInvoiceMasterBll.GetDataByInvoiceID(int.Parse(s1)); string str1 = this.objInvoiceMasterDT.Rows[0]["InvoiceNumber"].ToString(); string s2 = this.objInvoiceMasterDT.Rows[0]["InvoiceTotal"].ToString(); //string s3 = this.objInvoiceMasterDT.Rows[0]["PaidToDate"].ToString(); //Decimal num = Decimal.Parse(s2) - Decimal.Parse(s3); Decimal num = Decimal.Parse(s2); string s4 = this.objInvoiceMasterDT.Rows[0]["ClientID"].ToString(); string str2 = string.Empty; string address1 = string.Empty; string str3 = string.Empty; string str4 = string.Empty; string str5 = string.Empty; this.objCompanyClientMasterDT = this.objCompanyClientMasterBll.GetDataByCompanyClientID(int.Parse(s4)); if (this.objCompanyClientMasterDT.Rows.Count > 0) { string username = this.objCompanyClientMasterDT.Rows[0]["UserName"].ToString(); str3 = this.objCompanyClientMasterDT.Rows[0]["OrganizationName"].ToString(); str4 = this.objCompanyClientMasterDT.Rows[0]["FirstName"].ToString(); str5 = this.objCompanyClientMasterDT.Rows[0]["LastName"].ToString(); address1 = this.objCompanyClientMasterDT.Rows[0]["Email"].ToString(); MembershipUser user = Membership.GetUser(username); if (user != null) { string key1 = PaymentMaster.GenerateCode(); string str6 = HttpUtility.UrlEncode(this.Encrypt(user.UserName, key1)); string password = user.GetPassword(); string key2 = PaymentMaster.GenerateCode(); string str7 = HttpUtility.UrlEncode(this.Encrypt(password, key2)); str2 = string.Format("{5}/CheckClient.aspx?page=invoice&anyId={0}&name={1}&tech={2}&keyname={3}&keytech={4}", (object)s1, (object)str6, (object)str7, (object)key1, (object)key2, Common.CommonHandler.WebsiteBaseURL); } } string str8 = string.Empty; string str9 = string.Empty; string address2 = "*****@*****.**"; this.objSMTPSettingsDT = this.objSMTPSettingsBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value)); if (this.objSMTPSettingsDT.Rows.Count > 0) { str9 = this.objSMTPSettingsDT.Rows[0]["EmailSignature"].ToString(); address2 = this.objSMTPSettingsDT.Rows[0]["SMTPFrom"].ToString(); } this.objNewPaymentEmailTemplateDT = this.objNewPaymentEmailTemplateBll.GetDataByCompanyID(int.Parse(this.hfCompanyID.Value), "other"); if (this.objNewPaymentEmailTemplateDT.Rows.Count > 0) { str8 = this.objNewPaymentEmailTemplateDT.Rows[0]["EmailBody"].ToString(); } Hashtable Variables = new Hashtable() { { (object)"company", (object)displayName }, { (object)"companyName", (object)displayName }, { (object)"invoiceNum", (object)str1 }, { (object)"invoiceNumber", (object)str1 }, { (object)"someLink", (object)str2 }, { (object)"emailTemplate", (object)str8 }, { (object)"companyEmail", (object)("<a href=\"mailto:" + addresses + "\">" + addresses + "</a>") }, { (object)"amountOwned", (object)num }, { (object)"clientOrgName", (object)str3 }, { (object)"firstName", (object)str4 }, { (object)"lastName", (object)str5 }, { (object)"invoiceAmt", (object)s2 }, { (object)"directLink", (object)this.directLink }, { (object)"branding", (object)this.branding }, { (object)"emailSign", (object)str9 }, { (object)"loginLink", (object)"<a target=\"_blank\" href=\"http://www.billtransact.com/MemberArea.aspx\">https://www.billtransact.com/MemberArea.aspx</a>" } }; Parser parser1 = new Parser(this.Server.MapPath("~/MailTemplate/PaymentInformationNew.html"), Variables); string path1 = this.Server.MapPath("~\\TempHTMLFiles\\"); File.WriteAllText(Path.Combine(path1, "Payment.html"), parser1.Parse()); Parser parser2 = new Parser(path1 + "Payment.html", Variables); try { //MailMessage message = new MailMessage() //{ // From = new MailAddress(address2, displayName) //}; //message.To.Add(new MailAddress(address1)); //message.ReplyToList.Add(addresses); //message.Subject = displayName + " has received your payment for invoice " + str1 + " in Bill Transact"; //message.BodyEncoding = Encoding.UTF8; //message.Body = parser2.Parse(); //message.IsBodyHtml = true; //Common.CommonHandler.SendSMTPEmail(hfCompanyID.Value, address1, displayName + " has received your payment for invoice " + str1 + " in Bill Transact", parser2.Parse(), true); await Common.CommonHandler.SendMail(hfCompanyID.Value, address1, displayName + " has received your payment for invoice " + str1 + " in Bill Transact", parser2.Parse(), true); //SmtpClientForCompany.smtpClient(this.hfCompanyID.Value).Send(message); } catch (Exception ex) { this.DisplayAlert("Error in sending mail." + (object)ex); } }