在ASP.NET中发送邮件 [英] Mail Sending in ASP.NET

查看:127
本文介绍了在ASP.NET中发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用asp.net 3.5版本,并尝试从我的应用程序发送电子邮件.我正在使用以下代码:

Hi,
I am using asp.net 3.5 version and trying to send email from my application. I am using following codes:

MailMessage Mail = new MailMessage();
Mail.From = new System.Net.Mail.MailAddress("username");
Mail.To.Add("recipient mail id");
Mail.Subject = TextBox3.Text;
Mail.Body = TextBox4.Text;
Mail.Priority = MailPriority.High;

SmtpClient smtp = new SmtpClient("smtp.gmail.com");
smtp.Credentials = new System.Net.NetworkCredential("username", "password");
smtp.EnableSsl = true;
smtp.Send(Mail);



但是我遇到以下错误:
The requested address is not valid in its context 74.125.47.109:25

谁能给我发送正确的代码来解决此错误.



But I am getting following error:
The requested address is not valid in its context 74.125.47.109:25

Can anyone send me the proper code to resolve this error.

推荐答案

端口是否打开?防火墙权限到位了吗?
进一步确保已在Web.Config中配置SMTP配置:
Is the port open? Firewall permissions in place?
Further make sure you have configured SMTP configuration in Web.Config:
<system.net>
   <mailSettings>
     <smtp from="abc@somedomain.com">
       <network host="somesmtpserver" port="25" userName="name" password="pass" defaultCredentials="true" />
     </smtp>
   </mailSettings>
</system.net>


如果需要,请查看此Microsoft Video教程:
使用ASP.NET发送来自网站的电子邮件 [


If needed, have a look at this Microsoft Video tutorial:
Use ASP.NET to send Email from Website[^]
If needed, there are lots of article on this very site on how to send emails.


阅读此内容
http://classicasp.aspfaq.com/email/how- do-i-send-e-mail-with-cdo.html [
Read this
http://classicasp.aspfaq.com/email/how-do-i-send-e-mail-with-cdo.html[^]


在将以下代码添加到web.config时出现错误
I am getting error on adding following code to web.config
<system.net>
    <mailSettings>
      <smtp from="abc@somedomain.com">
        <network host="somesmtpserver" port="25" userName="name" password="pass" defaultCredentials="true" />
      </smtp>
    </mailSettings>
 </system.net>



错误是:
请求的地址在其上下文中无效74.125.65.109:25

请让我知道解决方案.



Error is :
The requested address is not valid in its context 74.125.65.109:25

Please let me know the solution for this.


这篇关于在ASP.NET中发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆