private void SendOnePaymentMail(SmtpClient smtpClient, BookingPayment paymentItem) { MailMessage message = new MailMessage(); List <Customer> customers = ApartmentMethods.ListCustomer(null, paymentItem.CustomerId, null, null, null, false, null, null, true); string email = string.Empty; if (customers.Count > 0 && customers[0].ContactInformation != null && !string.IsNullOrEmpty(customers[0].ContactInformation.Email)) { email = customers[0].ContactInformation.Email; } if (!string.IsNullOrEmpty(email)) { string dateFormat = "dd-MMM-yyyy"; string moneyFormat = "C0"; message.To.Add(new MailAddress(email)); string subject = string.Format("Payment Details from {0} to {1}", paymentItem.DateStart.ToString(dateFormat), paymentItem.DateEnd.ToString(dateFormat)); message.Subject = subject; message.IsBodyHtml = true; using (FileStream stream = File.OpenRead(HttpContext.Current.Server.MapPath("/EmailTemplates/MonthlyPayment.htm"))) { StringBuilder strb = new StringBuilder(); byte[] b = new byte[stream.Length]; UTF8Encoding temp = new UTF8Encoding(true); while (stream.Read(b, 0, b.Length) > 0) { strb.Append(temp.GetString(b)); } string content = strb.ToString(); CultureInfo customCultureInfo = new CultureInfo(MimosaSettings.GloblaCulture()); customCultureInfo.NumberFormat = (new CultureInfo(MimosaSettings.NumberFormatCulture())).NumberFormat; customCultureInfo.DateTimeFormat = (new CultureInfo(MimosaSettings.DateTimeFormatCulture())).DateTimeFormat; Thread.CurrentThread.CurrentCulture = customCultureInfo; content = string.Format(content, paymentItem.CustomerName, subject, paymentItem.SiteName, paymentItem.RoomName, paymentItem.DateStart.ToString(dateFormat), paymentItem.DateEnd.ToString(dateFormat), paymentItem.RoomPrice.ToString(moneyFormat), paymentItem.EquipmentPrice.ToString(moneyFormat), paymentItem.ServicePrice.ToString(moneyFormat), paymentItem.TotalPrice.ToString(moneyFormat), paymentItem.CustomerPaid.ToString(moneyFormat), paymentItem.MoneyLeft.ToString(moneyFormat)); message.Body = content; smtpClient.Send(message); } } }
public AppSettings GetAppSettings() { AppSettings appSettings = new AppSettings(); appSettings.GloblaCulture = MimosaSettings.GloblaCulture(); appSettings.NumberFormatCulture = MimosaSettings.NumberFormatCulture(); appSettings.DateTimeFormatCulture = MimosaSettings.DateTimeFormatCulture(); appSettings.MainCurrency = MimosaSettings.MainCurrency(); appSettings.SecondCurrency = MimosaSettings.SecondCurrency(); appSettings.VirtualDirectory = MimosaSettings.VirtualDirectory(); decimal rate = ConvertCurrency(appSettings.SecondCurrency, appSettings.MainCurrency); appSettings.ExchangeRate = rate; return(appSettings); }