不管我怎么样,总是提示说发送失败,服务器不支持安全连接,请各位大侠帮我看看,谢谢!!!
protected void Button3_Click(object sender, EventArgs e)
{
MailMessage mailMessage = new MailMessage();
string strBody; mailMessage.From = new MailAddress("####@126.com");
mailMessage.To.Add("#####@cswrtz.com");//企业邮箱
mailMessage.Subject = "速取黑马"; strBody = "<h2>" + this.TextBox5 + "</h2><br><h2>" + this.DropDownList1.SelectedValue + "</h2><br><h2>" + this.TextBox6 + "</h2><br><h2>";
sendMail(mailMessage);
}
public void sendMail(MailMessage mail)
{
SmtpClient smtpClient = new SmtpClient();
smtpClient.EnableSsl = true;
smtpClient.Host = "smtp.126.com";
smtpClient.Port = 25;
smtpClient.Credentials = new System.Net.NetworkCredential("####", "####");
try
{
smtpClient.Send(mail);
colse();
}
catch (Exception ex)
{
HttpContext.Current.Response.Write(ex.Message);
} }
protected void Button3_Click(object sender, EventArgs e)
{
MailMessage mailMessage = new MailMessage();
string strBody; mailMessage.From = new MailAddress("####@126.com");
mailMessage.To.Add("#####@cswrtz.com");//企业邮箱
mailMessage.Subject = "速取黑马"; strBody = "<h2>" + this.TextBox5 + "</h2><br><h2>" + this.DropDownList1.SelectedValue + "</h2><br><h2>" + this.TextBox6 + "</h2><br><h2>";
sendMail(mailMessage);
}
public void sendMail(MailMessage mail)
{
SmtpClient smtpClient = new SmtpClient();
smtpClient.EnableSsl = true;
smtpClient.Host = "smtp.126.com";
smtpClient.Port = 25;
smtpClient.Credentials = new System.Net.NetworkCredential("####", "####");
try
{
smtpClient.Send(mail);
colse();
}
catch (Exception ex)
{
HttpContext.Current.Response.Write(ex.Message);
} }
解决方案 »
- ASP+ACC,如何调用近30天内的数据?
- nettiers中控件实体类绑定的问题
- 操作系统windows2003打完补丁,ASP.NET出现错误 跪求解决方法~~~
- XmlDocument 对字符串的操作
- 怎么在dataset中载入xml字符串
- google map 模拟器
- 列表框疑问,各位高手帮忙!
- System.net.socket问题;
- ASP.NET 后台如何调用前台引用的JS文件中的javascript函数??
- 求教当前流行的类似Infragistics2.WebUI.UltraWebChart的插件
- 有谁知道在哪里下Adobe Premiere 免费简体中文版
- 把这个ASP里的链接转换为.NET里的链接
{
try
{
CDO.Message oMsg = new CDO.Message();
oMsg.From = f_email;
oMsg.To = t_email;
oMsg.Subject = "东风威客取回密码 ";
oMsg.HTMLBody = " <html > <body >这是您的帐号信息: <br >帐号: "+zh+ " <br >密码: "+mm+ " <br > <a href= 'http://www.33419.cn ' >东风工作室 </a > </body > </html > ";
CDO.IConfiguration iConfg = oMsg.Configuration;
ADODB.Fields oFields = iConfg.Fields;
oFields[ "http://schemas.microsoft.com/cdo/configuration/sendusing "].Value=2;
oFields[ "http://schemas.microsoft.com/cdo/configuration/sendemailaddress "].Value=f_email; //sender mail
oFields[ "http://schemas.microsoft.com/cdo/configuration/smtpaccountname "].Value=f_email; //email account
oFields[ "http://schemas.microsoft.com/cdo/configuration/sendusername "].Value= "roamabout ";
oFields[ "http://schemas.microsoft.com/cdo/configuration/sendpassword "].Value= "kk123 ";
oFields[ "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate "].Value=1;
//value=0 代表Anonymous验证方式(不需要验证)
//value=1 代表Basic验证方式(使用basic (clear-text) authentication.
//The configuration sendusername/sendpassword or postusername/postpassword fields are used to specify credentials.)
//Value=2 代表NTLM验证方式(Secure Password Authentication in Microsoft Outlook Express)
oFields[ "http://schemas.microsoft.com/cdo/configuration/languagecode "].Value=0x0804;
oFields[ "http://schemas.microsoft.com/cdo/configuration/smtpserver "].Value= "smtp.126.com ";
oFields.Update();
oMsg.BodyPart.Charset= "gb2312 ";
oMsg.HTMLBodyPart.Charset= "gb2312 ";
oMsg.Send();
oMsg = null;
}
catch (Exception e)
{
throw e;
}
} 再添加一个引用,如果你是xp系统请到c:\windiws下找到cdosys.dll,如果是2000到c:\winnet找cdosys.dll(不要说不会添加引用吧???)
而且报的错我也看不明白。 谢谢
{
MailMessage objMailMessage;
//创建邮件信息
objMailMessage = new MailMessage();
objMailMessage.From="[email protected]";
objMailMessage.To=tomail;
objMailMessage.BodyFormat=MailFormat.Html;
objMailMessage.Subject=subject;
objMailMessage.Body=body; //接着利用sina的SMTP来发送邮件,需要使用Microsoft .NET Framework SDK v1.1和它以上的版本 //基本权限
objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
//用户名
objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "mailname") ;
//密码
objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "********"); //如果没有上述三行代码,则出现如下错误提示:服务器拒绝了一个或多个收件人地址。服务器响应为: 554 : Client host rejected: Access denied //SMTP地址
SmtpMail.SmtpServer = "smtp.163.com"; //开始发送邮件
SmtpMail.Send( objMailMessage ); }