private void SendMailByWeb()
{
MailMessage objMailMessage = new MailMessage();
SmtpMail.SmtpServer =System.Configuration.ConfigurationManager.AppSettings["SMTP"];
objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "2622703973@qq.com");
objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", System.Configuration.ConfigurationManager.AppSettings["PWD"]);//密码可以不提供 objMailMessage.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", "true");//SMTP 服务器要求安全连接需要设置此属性
objMailMessage.BodyEncoding = System.Text.Encoding.UTF8; objMailMessage.From = "mysendmc@sina.com";
objMailMessage.To = Request.Form["Textemail"]; objMailMessage.Subject = "this is test";
objMailMessage.Body = "Hi Pippo,<br/>This is testing EMAIL."; objMailMessage.BodyFormat = MailFormat.Html;
SmtpMail.SmtpServer = "smtp.sina.com.cn";
try {
SmtpMail.Send(objMailMessage);
Response.Write("发送成功");
}
catch (Exception ex) {
Response.Write(ex.Message);
}
}
用System.Net.Mail命名空间类进行发送吧
亲,不行,该了以后都报错了
@简单的@快乐:
报什么错呢?
1、我看你的SMTPCLIENT设置为smtp.sina.com.cn新浪服务器
但是你的发送用户名却是:2622703973@qq.com (QQ邮箱)--是不是账号错了
2、没看到你设置SMTPClient端口号,是不是与SSL对应的端口号不一致
呵呵呵,我已经把问题解决了,谢谢
这个代码没法看,建议给代码加上着色,编辑器中有个“插入代码”的按钮
这样行吗
@简单的@快乐: 哈哈哈,好幽默
呵呵呵,我已经把问题解决了,谢谢
先断点跟,到底是哪句话出现的错误,然后你最好把你配置的SMTP服务器和端口啥的贴出来,你的配置文件存的啥,我们又看不到~
呵呵呵,我已经把问题解决了,谢谢