我的代码里的发送邮件的方法是这样的
public static void CDOsendmail(string from,string to,string subject,string body,string userName,string userPwd,string smtpServer)
{
MailMessage msg = new MailMessage();
msg.From =from;
msg.To = to;
msg.Subject = subject;
msg.Body = body;
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1);
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",userName);
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",userPwd);
SmtpMail.SmtpServer = smtpServer;
SmtpMail.Send(msg);
msg = null;
}
然后我的web.config中存了必要的一些数据,部分如下:
<appSettings>
<add key = "strcon" value = "server = .;database = eshop;uid = sa;pwd =" />
<add key="mailFrom" value="我的163登陆帐号"></add>
<add key="userName" value="[email protected]"></add>
<add key="password" value="我的密码"></add>
<add key="mailSubject" value="成功找回您的密码"></add>
<add key="mailSmtp" value="smtp.163.com"></add>
</appSettings> 这写代码至少在拼写上我都保证没有错,这些web.config中的值是会经过一个方法传给上面的CDOsendmail()方法的,但是在执行到CDOsendmail()方法中的 SmtpMail.Send(msg);时,就会抛出异常,请大哥们帮我检查看一下是怎么回事。我老是怀疑是不是163现在的smtpServer不是smtp.163.com
public static void CDOsendmail(string from,string to,string subject,string body,string userName,string userPwd,string smtpServer)
{
MailMessage msg = new MailMessage();
msg.From =from;
msg.To = to;
msg.Subject = subject;
msg.Body = body;
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate",1);
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername",userName);
msg.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword",userPwd);
SmtpMail.SmtpServer = smtpServer;
SmtpMail.Send(msg);
msg = null;
}
然后我的web.config中存了必要的一些数据,部分如下:
<appSettings>
<add key = "strcon" value = "server = .;database = eshop;uid = sa;pwd =" />
<add key="mailFrom" value="我的163登陆帐号"></add>
<add key="userName" value="[email protected]"></add>
<add key="password" value="我的密码"></add>
<add key="mailSubject" value="成功找回您的密码"></add>
<add key="mailSmtp" value="smtp.163.com"></add>
</appSettings> 这写代码至少在拼写上我都保证没有错,这些web.config中的值是会经过一个方法传给上面的CDOsendmail()方法的,但是在执行到CDOsendmail()方法中的 SmtpMail.Send(msg);时,就会抛出异常,请大哥们帮我检查看一下是怎么回事。我老是怀疑是不是163现在的smtpServer不是smtp.163.com
解决方案 »
- C#+vs2008+mssql2005 用什么版本控制器比较好
- “System.OutOfMemoryException”的异常 请问是怎么回事??
- 如何发布一个asp.net的网站??????
- asp.net操作Execl问题?
- 请问数据库从SQL SERVER 2005转移到Oracle10g需要做哪些东西
- 救命啊!谁能找到免费asp.net空间网站?
- 关于三层模式的项目开发
- 请提供一些比较靓的DataGrid的颜色搭配
- web打印出问题啦??
- 哪位大侠能解决?--关于输入控件的AutoPostBack的问题,在线等...
- dropdownlist问题
- [谢谢]split怎么样用呢??比如:
smtp.sina.com.cn
我前几天写的一个发邮件的程序也是用163发不出去,用新浪的就可以发出去
打消这个念头咯你先用自己的机器安装相关的组件布置成邮件服务器,测试下,另外是不是防火墙的问题?其次抛出什么异常?
=================
新浪有什么问题?