嗨,我正在尝试使用 gmail 凭据发送电子邮件并调用电子邮件模板,但它引发了发送邮件失败的异常
SmtpClient SmtpServer = new SmtpClient();
SmtpServer.Credentials = new System.Net.NetworkCredential("ambarishkesavarapu@gmail.com", "xxxxxx");
SmtpServer.Port = 587;
SmtpServer.Host = "smtp.gmail.com";
SmtpServer.EnableSsl = true;
message = new MailMessage();
message.Subject = "Visitor Arrived";
message.SubjectEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = false;
message.Body = "EmailTemplate.html";
message.BodyEncoding = System.Text.Encoding.UTF8;
message.From = new MailAddress("ambarishkesavarapu@gmail.com");
message.To.Add(lblCPEmail.Text);
message.Priority = MailPriority.High;
message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
SmtpServer.Send(message);
请帮帮我。