using System.Net.Mail;
MailMessage mm = new MailMessage();
mm.From =new MailAddress("[email protected]");
mm.To.Add(new MailAddress("[email protected]"));
mm.Subject = “123”;
mm.Body = “123”;
// HTML格式
mm.IsBodyHtml = true;
SmtpClient sc = new SmtpClient();
sc.Host = "smtp."+mm.From.Host;
sc.Port = 25;
sc.Credentials = new NetworkCredential("[email protected]", "123456");
try
{
sc.Send(mm);
Response.Write("ok");
}
catch (Exception ex)
{
// 与smtp相关的错误
if (ex is SmtpException)
{
// ex.ToString();
Response.Write(ex.Message);
}
else
{
Response.Write(ex.ToString());
}
}
会报以下错误:
SMTP 服务器要求安全连接或客户端未通过身份验证。 服务器响应为: Authentication required
谁知道SMTP的身份验证啊
不要给我下面的,因为我也试过还是要验证
using System.Web.Mail;
MailMessage mail = new MailMessage();
mail.From = "[email protected]";
mail.To = "[email protected]";
mail.Subject = ".net email";
mail.BodyFormat = MailFormat.Html;
mail.Body = "go go go";
SmtpMail.SmtpServer = "smtp.qq.com";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "[email protected]");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "xxxxxxxxx");
SmtpMail.Send(mail);
高手们告诉我下啊、、、、、、、、、、、、、、
MailMessage mm = new MailMessage();
mm.From =new MailAddress("[email protected]");
mm.To.Add(new MailAddress("[email protected]"));
mm.Subject = “123”;
mm.Body = “123”;
// HTML格式
mm.IsBodyHtml = true;
SmtpClient sc = new SmtpClient();
sc.Host = "smtp."+mm.From.Host;
sc.Port = 25;
sc.Credentials = new NetworkCredential("[email protected]", "123456");
try
{
sc.Send(mm);
Response.Write("ok");
}
catch (Exception ex)
{
// 与smtp相关的错误
if (ex is SmtpException)
{
// ex.ToString();
Response.Write(ex.Message);
}
else
{
Response.Write(ex.ToString());
}
}
会报以下错误:
SMTP 服务器要求安全连接或客户端未通过身份验证。 服务器响应为: Authentication required
谁知道SMTP的身份验证啊
不要给我下面的,因为我也试过还是要验证
using System.Web.Mail;
MailMessage mail = new MailMessage();
mail.From = "[email protected]";
mail.To = "[email protected]";
mail.Subject = ".net email";
mail.BodyFormat = MailFormat.Html;
mail.Body = "go go go";
SmtpMail.SmtpServer = "smtp.qq.com";
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "[email protected]");
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "xxxxxxxxx");
SmtpMail.Send(mail);
高手们告诉我下啊、、、、、、、、、、、、、、
解决方案 »
- 怪事!模态窗中的提交按钮???
- 关于iframe框架的问题
- 来者有分~~
- ====VS2005下,关于页面基类和问题====
- 用detailsview显示gridview 选择的详细信息
- ASP网页的运行原理和机制是什么?
- 在c#写dll里面怎样调用文本文件
- 对asp.net,HTML代码段中的Page_load(SRR AS OBJECT,E AS EVENTARGS)函数的困惑。
- 本拉要散分,却没有分了,对不起大家乐!网站终于发布成功了,大家多提意见!
- AjaxPro.Utility.RegisterTypeForAjax(typeof(ajax)) 解释
- 求图形控件 开源 免费的
- 登陆的问题!可不可以把我没有注释的补上,尽量详细一点,谢谢大家!
/// 发送用户账户激活邮件
/// </summary>
/// <param name="strSmtpServer">邮件发送服务器</param>
/// <param name="strFrom">发件人账号</param>
/// <param name="strFromPass">发件人密码</param>
/// <param name="strto">收件人账号</param>
/// <param name="strSubject">邮件主题</param>
/// <param name="strBody">邮件内容</param>
public void SendSMTPEMail(string strSmtpServer, string strFrom, string strFromPass, string strto, string strSubject, string strBody)
{
SmtpClient client = new SmtpClient(strSmtpServer);
client.UseDefaultCredentials = false;
client.Credentials = new NetworkCredential(strFrom, strFromPass);
client.DeliveryMethod = SmtpDeliveryMethod.Network; MailMessage message = new MailMessage(strFrom, strto, strSubject, strBody);
message.BodyEncoding = System.Text.Encoding.UTF8;
message.IsBodyHtml = true;
client.Send(message);
}你没有发件人邮箱密码……
传错了,改下