public void ReciveConfirmationViaEmail(List <OrderItem> orderItemsList, string inputEmail) { purchaseConfirmation = "You successfully purchased: "; email = ""; totalAmount = 0; paymentOption = ""; deliveryOption = ""; currency = ""; foreach (var item in orderItemsList) { purchaseConfirmation += $"{item.Quantity} of {item.Product.Name}, "; totalAmount = item.Order.TotalAmount; paymentOption = item.Order.PaymentOption; deliveryOption = item.Order.DeliveryOption; currency = item.Order.User.Currency; email = inputEmail ?? item.Order.User.Email; } purchaseConfirmation += $"for the amount of {CurrencyManager.CalcPrice((decimal)totalAmount, HttpContext.Session.GetString("currencyRate"))} {HttpContext.Session.GetString("currencyCode")} via { paymentOption}. Your delivery will arrive in { deliveryOption} days"; recipient = email; subject = "Order Confirmation"; body = purchaseConfirmation; MailMessage mm = new MailMessage(); mm.To.Add(recipient); mm.Subject = subject; mm.Body = body; mm.From = new MailAddress("*****@*****.**", "OMGZ Shoes"); mm.IsBodyHtml = false; SmtpClient smtp = new SmtpClient("smtp.gmail.com") { Port = 587, UseDefaultCredentials = false, EnableSsl = true, Credentials = new System.Net.NetworkCredential("*****@*****.**", "OmgzOmgz123") }; smtp.Send(mm); }