public void ProcessOrder(Entities.Cart cart, Entities.ShippingDetails shippingInfo) { using (SmtpClient smtpClient = new SmtpClient()) { smtpClient.EnableSsl = emailSettings.UseSsl; smtpClient.Host = emailSettings.Servername; smtpClient.Port = emailSettings.ServerPort; smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = new NetworkCredential(emailSettings.Username, emailSettings.Password); if (emailSettings.WriteAsFile) { smtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; smtpClient.PickupDirectoryLocation = emailSettings.FileLocation; smtpClient.EnableSsl = false; } StringBuilder body = new StringBuilder() .AppendLine("A new order has been submitted") .AppendLine("---") .AppendLine("Items:"); foreach (var line in cart.Lines) { var subtotal = line.Product.Price * line.Quantity; body.AppendFormat("{0} x {1} (subtotal: {2:c}", line.Quantity, line.Product.Name, subtotal); } body.AppendFormat("Total order value: {0:c}", cart.ComputeTotalValue()) .AppendLine("---") .AppendLine("Ship to:") .AppendLine(shippingInfo.Name) .AppendLine(shippingInfo.Line1) .AppendLine(shippingInfo.Line2 ?? "") .AppendLine(shippingInfo.Line3 ?? "") .AppendLine(shippingInfo.City) .AppendLine(shippingInfo.State ?? "") .AppendLine(shippingInfo.Country) .AppendLine(shippingInfo.Zip) .AppendLine("---") .AppendFormat("Gift wrap: {0}", shippingInfo.GiftWrap ? "Yes" : "No"); MailMessage mailMessage = new MailMessage( emailSettings.MailFromAddress, // From emailSettings.MailToAddress, // To "New order submitted!", // Subject body.ToString()); // Body if (emailSettings.WriteAsFile) { mailMessage.BodyEncoding = Encoding.ASCII; } smtpClient.Send(mailMessage); } }
public void ProcessOrder(Entities.Cart cart, Entities.ShippingDetails shippingDetails) { using (var smtpClient = new SmtpClient()) { smtpClient.EnableSsl = emailSettings.UseSsl; smtpClient.Host = emailSettings.ServerName; smtpClient.Port = emailSettings.ServerPort; smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = new NetworkCredential(emailSettings.Username, emailSettings.Password); if (emailSettings.WriteAsFile) { smtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; smtpClient.PickupDirectoryLocation = emailSettings.FileLocation; smtpClient.EnableSsl = false; } StringBuilder body = new StringBuilder() .AppendLine("Новый заказ обработан") .AppendLine("---") .AppendLine("Товары:"); foreach (var line in cart.Lines) { var subtotal = line.Book.Price * line.Quantity; body.AppendFormat("{0} x {1} (итого: {2:c}", line.Quantity, line.Book.Name, subtotal); } body.AppendFormat("Общая стоимость: {0:c}", cart.ComputeTotalValue()) .AppendLine("---") .AppendLine("Доставка:") .AppendLine(shippingDetails.Name) .AppendLine(shippingDetails.Line1) .AppendLine(shippingDetails.Line2 ?? "") .AppendLine(shippingDetails.Line3 ?? "") .AppendLine(shippingDetails.City) .AppendLine(shippingDetails.Country) .AppendLine("---") .AppendFormat("Упаковка: {0}", shippingDetails.GiftWrap ? "Да" : "Нет"); MailMessage mailMessage = new MailMessage( emailSettings.MailFromAddress, emailSettings.MailToAddress, "Новый заказ отправлен!", body.ToString() ); if (emailSettings.WriteAsFile) { mailMessage.BodyEncoding = Encoding.UTF8; } smtpClient.Send(mailMessage); } }
public void ProcessOrder(Entities.Cart cart, Entities.ShippingDetails shippingDetails) { using (var smtpClient = new SmtpClient()) { smtpClient.EnableSsl = emailSettings.UseSsl; smtpClient.Host = emailSettings.ServerName; smtpClient.Port = emailSettings.ServerPort; smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = new NetworkCredential(emailSettings.Username, emailSettings.Password); if (emailSettings.WriteAsFile) { smtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; smtpClient.PickupDirectoryLocation = emailSettings.FileLocation; smtpClient.EnableSsl = false; } StringBuilder body = new StringBuilder() .AppendLine("Нове замовлення опрацьоване") .AppendLine("---") .AppendLine("Товари:"); foreach (var line in cart.Lines) { var subtotal = line.Product.Price * line.Quantity; body.AppendFormat("{0} x {1} (Всього: {2:c}", line.Quantity, line.Product.Name, subtotal); } body.AppendFormat("Загальна вартість: {0:c}", cart.ComputeTotalValue()) .AppendLine("---") .AppendLine("Доставка:") .AppendLine(shippingDetails.Name) .AppendLine(shippingDetails.Line1) .AppendLine(shippingDetails.Line2 ?? "") .AppendLine(shippingDetails.Line3 ?? "") .AppendLine(shippingDetails.City) .AppendLine(shippingDetails.Phone) .AppendLine("---") .AppendFormat("Подарункове пакування: {0}", shippingDetails.GiftWrap ? "Так" : "Ні"); MailMessage mailMessage = new MailMessage( emailSettings.MailFromAddress, emailSettings.MailToAddress, "Нове замовлення відправлене!", body.ToString() ); if (emailSettings.WriteAsFile) { mailMessage.BodyEncoding = Encoding.UTF8; } smtpClient.Send(mailMessage); } }
public void OrderProcess(Cart cart, Entities.ShippingDetails shippingDetails) { using (var smtpClient = new SmtpClient()) { smtpClient.EnableSsl = emailSettings.UseSsl; smtpClient.Host = emailSettings.ServerName; smtpClient.Port = emailSettings.ServerPort; smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = new NetworkCredential(emailSettings.UserName, emailSettings.Password); if (emailSettings.WriteAsFile) { smtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; smtpClient.PickupDirectoryLocation = emailSettings.FileLocation; smtpClient.EnableSsl = false; } StringBuilder body = new StringBuilder() .AppendLine("New order processed") .AppendLine(string.Empty) .AppendLine("Goods:"); foreach (var line in cart.Lines) { var subTotal = line.Game.Price * line.Quantity; body.AppendFormat("{0} x {1} (Total: {2:c})", line.Quantity, line.Game.Name, subTotal); body.AppendLine(string.Empty); } body.AppendFormat("Total cost: {0:c}", cart.ComputeTotalValue()) .AppendLine(string.Empty) .AppendLine("Delivery") .AppendLine(shippingDetails.Name) .AppendLine(shippingDetails.Line1) .AppendLine(shippingDetails.Line2 ?? string.Empty) .AppendLine(shippingDetails.Line3 ?? string.Empty) .AppendLine(shippingDetails.City) .AppendLine(shippingDetails.Country) .AppendLine(string.Empty) .AppendFormat("Gift Wrap: {0}", shippingDetails.GiftWrap ? "Yes" : "No"); MailMessage mailMessage = new MailMessage( emailSettings.MailFromAddress, // От кого emailSettings.MailToAddress, // Кому "New order sent!", // Тема body.ToString()); // Тело письма if (emailSettings.WriteAsFile) { mailMessage.BodyEncoding = Encoding.UTF8; } smtpClient.Send(mailMessage); //google email account-ში უნდა ჩავრთოთ Acess for less secure apps წინააღმდეგ შემთხვევაში დაგენერირდება smtpexception } }
public void ProcessOrder(Entities.Cart cart, Entities.ShippingDetails shippingInfo) { using (var smtpClient = new SmtpClient()) { smtpClient.EnableSsl = emailSettings.UseSsl; smtpClient.Host = emailSettings.ServerName; smtpClient.Port = emailSettings.ServerPort; smtpClient.UseDefaultCredentials = false; smtpClient.Credentials = new NetworkCredential(emailSettings.UserName, emailSettings.Password); StringBuilder emailBody = new StringBuilder() .AppendLine("A new order has been submitted") .AppendLine("---") .AppendLine("Items:"); foreach (var line in cart.CartItems) { var subtotal = line.Product.Price * line.Quantity; emailBody.AppendFormat("{0} x {1} (subtotal: {2:c})\n", line.Quantity, line.Product.Name, subtotal); } emailBody.AppendFormat("Total order value: {0:c}", cart.ComputeTotalPrice()) .AppendLine("---") .AppendLine("Ship to:") .AppendLine(shippingInfo.Name) .AppendLine(shippingInfo.AddressLine1) .AppendLine(shippingInfo.AddressLine2 ?? "") .AppendLine(shippingInfo.AddressLine3 ?? "") .AppendLine(shippingInfo.City) .AppendLine(shippingInfo.State ?? "") .AppendLine(shippingInfo.Country) .AppendLine(shippingInfo.Zip) .AppendLine("---") .AppendFormat("Gift wrap: {0}", shippingInfo.GiftWrap ? "Yes" : "No"); MailMessage mailMessage = new MailMessage(new MailAddress(emailSettings.MailFromAddress).Address, new MailAddress(emailSettings.MailToAddress).Address, "New order submitted!", emailBody.ToString()); smtpClient.Send(mailMessage); } }
public void ProcessOrder(Entities.Cart cart, Entities.ShippingDetails shippingDetails) { }
public void ProcessOrder(Entities.Cart cart, Entities.ShippingDetails shippingDetails) { using (var smtpClient = new SmtpClient()) { smtpClient.EnableSsl = emailSetting.UseSsl; smtpClient.Host = emailSetting.ServerName; smtpClient.Port = emailSetting.ServerPort; ////////////////////////////////// //smtpClient.Timeout = 10000; //hl ha4ta8l b el72o2 el3adia smtpClient.UseDefaultCredentials = false; //hay4ta8l 3la dol m4 3 el default smtpClient.Credentials = new NetworkCredential(emailSetting.UserName, emailSetting.Password); if (emailSetting.WriteAsFile) { //hadek file feh el emails tb3t mno smtpClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory; /////// //smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network; //// smtpClient.PickupDirectoryLocation = emailSetting.FileLocation; //talma feh file yb3t mno m4 haynf3 ykon feh ssl smtpClient.EnableSsl = false; } //body el message StringBuilder body = new StringBuilder() .AppendLine("A new order has been submitted") .AppendLine("------------") .AppendLine("Books: "); foreach (var line in cart.Lines) { var subtotal = line.Book.Price * line.Quantity; body.AppendFormat("{0} x {1} (subtotal: {2:c} )", line.Quantity, line.Book.Title, subtotal); } body.AppendFormat("Total order value : {0:c}", cart.ComputeTotalValue()) .AppendLine("----------") .AppendLine("Ship to") .AppendLine(shippingDetails.Name) .AppendLine(shippingDetails.Line1) .AppendLine(shippingDetails.Line2) .AppendLine(shippingDetails.State) .AppendLine(shippingDetails.City) .AppendLine(shippingDetails.Country) .AppendLine("-----------") .AppendFormat("Gift wrap:{0} ", shippingDetails.GiftWrap ? "Yes" : "No"); //byzbt el message b4akl kamel MailMessage mailMessage = new MailMessage( emailSetting.MailFromAddress, emailSetting.MailToAddress, "New order submited", body.ToString() ); if (emailSetting.WriteAsFile) { mailMessage.BodyEncoding = Encoding.ASCII; } try { smtpClient.Send(mailMessage); }catch (Exception ex) { Debug.Print(ex.Message); } } }
public void ProcessOrder(Entities.Cart p_Cart, Entities.ShippingDetails p_ShippingDetails) { }