在ASP .NET中发送邮件(SMTP) [英] Send Mail in ASP .NET (SMTP)
本文介绍了在ASP .NET中发送邮件(SMTP)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我写了下面code在我的code文件。但它没有工作... plz帮助我! :)
I wrote the following code in my code file. But it does not work... plz help me! :)
protected void Button1_Click(object sender, EventArgs e)
{
MailMessage msgeme = new MailMessage("someone@example.com", "someone@example.com", "subject", "body");
SmtpClient smtpclient = new SmtpClient("smtp.gmail.com",587);
smtpclient.EnableSsl = true;
smtpclient.Send(msgeme);
smtpclient.Credentials = new NetworkCredential("someone@example.com", "password");
}
我都试过587和465的Bt它显示了SMTP异常处理程序错误。谁能帮助???
I tried both 587 and 465. Bt it shows SMTP Exception handler error. Can anyone help???
推荐答案
尝试使用不同的枚举添加DeliveryMethod,也发送前凭据:
try to add DeliveryMethod with the different enumerations, and also credentials before send:
MailMessage msgeme = new MailMessage("someone@example.com", "someone@example.com", "subject", "body");
SmtpClient smtpclient = new SmtpClient("smtp.gmail.com",587);
smtpclient.EnableSsl = true;
smtpclient.Credentials = new NetworkCredential("someone@example.com", "password");
smtpclient.DeliveryMethod = SmtpDeliveryMethod.Network;
smtpclient.Send(msgeme);
这篇关于在ASP .NET中发送邮件(SMTP)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文