嗨,我正在尝试使用Gmail凭证和调用电子邮件模板发送一封电子邮件,但它抛出一个异常发送邮件失败发送与使用Gmail凭证
SmtpClient SmtpServer = new SmtpClient();
SmtpServer.Credentials = new System.Net.NetworkCredential("[email protected]", "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("[email protected]");
message.To.Add(lblCPEmail.Text);
message.Priority = MailPriority.High;
message.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
SmtpServer.Send(message);
请帮我出模板电子邮件。
欢迎来到SO。它有助于解释为什么你的答案是正确的,而不是只发布代码。 – 2016-11-03 07:52:16