如何在ASP .NET中发送电子邮件? [英] how to send email in ASP .NET?
本文介绍了如何在ASP .NET中发送电子邮件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨....我开发了一个我想发送电子邮件的应用程序。但是它给我一个错误试图以一种禁止其访问权限的方式访问套接字[2607:f8b0:400e:c02 :: 6d]:587。请帮我。在此先感谢。
Web.Config文件:
Hi.... I have developed an application where I want to send email. But it''s getting me an error "An attempt was made to access a socket in a way forbidden by its access permissions [2607:f8b0:400e:c02::6d]:587". Please Help me. Thanks in advance.
Web.Config File:
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
</system.web>
<appSettings>
<add key="SendMail" value="true"/>
</appSettings>
</configuration>
CS档案:
CS File:
protected void Button1_Click(object sender, EventArgs e)
{
MailMessage mail = new MailMessage("xxxxxxxx@gmail.com", "xxxxxxxx@gmail.com");
mail.Subject = "Mail Message";
mail.Body = TextBox1.Text;
SmtpClient sc = new SmtpClient("smtp.gmail.com", 587);
sc.Credentials = new System.Net.NetworkCredential()
{
UserName = "xxxxxxxx@gmail.com",
Password = "********"
};
sc.EnableSsl = true;
sc.Send(mail);// My browser shows above error at this point.
}
删除电子邮件地址(将原始地址更改为xxxxxxxx@gmail.com)[/编辑]
Email address removed (changed original address into xxxxxxxx@gmail.com)[/Edit]
推荐答案
您好 @Chiklu.Soumya ,
请关注我的回答 - 从asp.net发送电子邮件到gmail [ ^ ]。
此代码工作正常。
请正确更换您的电子邮件ID和密码并进行测试。
如果您遇到任何困难,请回复我。
Hello @Chiklu.Soumya,
Please follow my answer - sending email to gmail from asp.net[^].
This code is working perfectly.
Please replace your email ids and passwords correctly and test.
In case you face any difficulty, please reply me.
这篇关于如何在ASP .NET中发送电子邮件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文