从asp.net应用程序发送电子邮件 [英] send email from asp.net app

查看:69
本文介绍了从asp.net应用程序发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将所有设置配置为使用C#发送电子邮件,但是执行时,出现以下错误请求的地址在其上下文中无效74.125.53.109:25

i configure all setting for send email using c# but when i execute than i get the following error The requested address is not valid in its context 74.125.53.109:25

我的代码是

MailMessage mail = new MailMessage();
mail.To.Add("to@gmail.com");
mail.From = new MailAddress("from@gmail.com");
mail.Subject = "Test Email";

string Body = "<b>Welcome to CodeDigest.Com!!</b>";
mail.Body = Body;
mail.IsBodyHtml = true;

SmtpClient smtp = new SmtpClient();
smtp.Host = ConfigurationManager.AppSettings["SMTP"];
smtp.Credentials = new System.Net.NetworkCredential(ConfigurationManager.AppSettings["FROMEMAIL"], ConfigurationManager.AppSettings["FROMPWD"]);
smtp.EnableSsl = true;   
smtp.Send(mail);

Web.Config

Web.Config

<appSettings>

    <add key="SMTP" value="smtp.gmail.com"/>

    <add key="FROMEMAIL" value="mail@gmail.com"/>

    <add key="FROMPWD" value="password"/>

  </appSettings>

推荐答案

在.NET通过Gmail 此链接包含发送电子邮件的完整代码及其正常工作在我的电脑中通过gmail发送电子邮件.

Sending email in .NET through Gmail This link have a full code of sending email and its proper working sending email by gmailin my pc.

这篇关于从asp.net应用程序发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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