Syntax error, command unrecognized. The server response was: authentication failed. asp.net 写stmp企业邮箱发送邮件时出的错误,问题解决就给分
解决方案 »
- 如何用程序在Global.ascx里增加Application变量啊?
- 怎么在ashx或者webservice里加载用户控件,然后获取这个用户控件的html?
- 关于用QQ企业邮箱发送邮件的问题
- 关于文件上传,判断大小的问题
- 地址栏加密
- ███100分求个简单的JS问题███
- flash实现登录的功能
- Smtp 認證時這句代表什麽意思?http://schemas.microsoft.com/cdo/configuration/smtpauthenticate
- 怎么使字符document输出alert的放映
- 我想将上面几个下拉列表框的选择项做为时间的“年” “月” “日” “小时” “分钟”!
- 请人开发一套ASP.NET的B2B电子商务系统大概需要多少钱?
- 如何动态绑定rdlc报表的数据源?
using System.Net.Mail; public static string SendMail(string toMail, string subject, string body, bool IsBodyHtml)
{
MailMessage mailMsg = new MailMessage();
string FormEmail = Configuration.Config.GetFromEmail();
mailMsg.From = new MailAddress(FormEmail, Configuration.Config.GetFromEmailDisName());
mailMsg.To.Add(toMail);
mailMsg.Subject = subject;
mailMsg.Body = body;
mailMsg.BodyEncoding = Encoding.UTF8;
mailMsg.IsBodyHtml = IsBodyHtml;
mailMsg.Priority = MailPriority.Normal; SmtpClient smtp = new SmtpClient();
// 提供身份验证的用户名和密码
// 网易邮件用户可能为:username password
// Gmail 用户可能为:[email protected] password
smtp.Credentials = new NetworkCredential(FormEmail, Configuration.Config.GetFromEmailPwd());
// 465 doesn't work with System.Net.Mail
smtp.Port = 587; // Gmail 使用 587 端口
smtp.Host = "smtp.gmail.com"; // 如 smtp.163.com, smtp.gmail.com
smtp.EnableSsl = true; // 如果使用GMail,则需要设置为true
//smtp.SendCompleted += new SendCompletedEventHandler(SendMailCompleted);
try
{
//object obj = mailMsg;
//smtp.SendAsync(mailMsg, obj);
smtp.Send(mailMsg);
return "ok";
}
catch (SmtpException ex)
{
return ex.ToString();
} }