The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.5.1 Authentication Required
private void SendEmail(string client, string clientemail, ArrayList orderList) { try { //SET UP SENDER AND RECEIVER E-MAIL ADDRESSES MailAddress to = new MailAddress(clientemail); //TODO: Fill in your own e-mail here! MailAddress from = new MailAddress("myemail@hotmail.com"); // SET UP EMAIL BODY/// StringBuilder sb = new StringBuilder(); sb.AppendFormat(@" Dear {0} We are happy to announce that your order placed on {1} has been completed and is ready for pickup. Your ordered products:", client, Request.QueryString["date"]); double total = 0; foreach (Order order in orderList) { sb.AppendFormat(@" - {0} ({1} €) X {2} = {3}", order.Product, order.Price, order.Amount, (order.Amount * order.Price)); total += (order.Amount * order.Price); } sb.Append(@" Total amount=" + total); sb.Append(@" You can come to receive your order at your earliest convenience. Kind regards"); // set up mail credentials MailMessage mail = new MailMessage(from, to); mail.Body = sb.ToString(); mail.Subject = "Your order has been completed"; // set up SMTP credentials SmtpClient smtp = new SmtpClient(); smtp.Host = "smtp.gmail.com"; smtp.EnableSsl = true; //TODO: Fill in your own e-mail and password here! smtp.Credentials = new NetworkCredential("myemail@hotmail.com", "mypassword"); smtp.UseDefaultCredentials = true; //smtp.Credentials = NetworkCred; smtp.Port = 587; // send email smtp.Send(clientemail);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)