public static void SendNotifications(Order order) { Sender EmailSender = new Sender ( host: "smtp.gmail.com", port: 587, enableSsl: true, deliveryMethod: SmtpDeliveryMethod.Network, useDefaultCredentials: false, credentials: new NetworkCredential("*****@*****.**", "aspnetbu") ); SendNotificationToCustomer(order, EmailSender); SendNotificationToShop(order, EmailSender); }
public static bool SendNotificationToShop(Order order, Sender EmailSender) { string subject = $"New order {Convert.ToString(order.Date)}!"; string body = GetMessageForShop(order); string toAddress = "*****@*****.**"; try { EmailSender.SendMail(subject, body, toAddress); return true; } catch { return false; } }
public static bool SendNotificationToCustomer(Order order, Sender EmailSender) { string subject = "MasterShop — New order"; string body = GetMessageForCustomer(order); string toAddress = order.Customer.Email; try { EmailSender.SendMail(subject, body, toAddress); return true; } catch { return false; } }