用.net发邮件,出现错误,在线等,高手过来帮忙!!!
System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient("smtp.163.com");
client.UseDefaultCredentials = true;
client.Credentials = new System.Net.NetworkCredential("t1estmail", "******");
client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;;
string strSubject = "测试";
string strBody = "测试测试测试测试";
System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage("t1estmail@163.com", "t2estmail@163.com", strSubject, strBody);
message.BodyEncoding = System.Text.Encoding.GetEncoding("gb2312");
message.SubjectEncoding = System.Text.Encoding.GetEncoding("gb2312");
message.IsBodyHtml = true;
message.Priority = System.Net.Mail.MailPriority.Normal;
client.Credentials = new System.Net.NetworkCredential("t1estmail@163.com", "******");
client.Send(message);
以上为发邮件代码,出现错误如下:Mailbox unavailable. The server response was: Óû§±»Ëø¶
我的代码是网上搜的,不知道哪里写的不对??? --------------------编程问答-------------------- 163免费邮件系统的POP3及SMTP服务将暂停开通 所以不能这样访问了 --------------------编程问答-------------------- 有没有人帮忙啊,急! --------------------编程问答-------------------- 啊,那用什么邮箱这样发比较好的? --------------------编程问答-------------------- 那些个免费邮件服务器一个个测试去吧,或者使用公司内部的邮件服务器。
没有别的办法。 --------------------编程问答-------------------- 首先,你用c#里自带这一套验证证书方法是通不过163的用户验证的。
给你一段用jmail组件发送的代码
jmail.Message myMail=new Message();
myMail.Charset="GB2312";
myMail.ContentTransferEncoding="GB2312";
myMail.Subject = "邮件标题";
myMail.Body="尊敬的XX"
myMail.Silent=true;
myMail.Logging=true;
myMail.From="****@163.com";
myMail.AddRecipient(mailto,"mailtest","A");
myMail.MailServerUserName="XXXXX@163.com";
myMail.MailServerPassWord="*****";
myMail.Send("smtp.163.com",false);
myMail.Close(); --------------------编程问答-------------------- 貌似我是沙发呢
这里有声明:
http://hi.baidu.com/ireg/blog/item/0cb6822b111e5ffae6cd40ac.html
--------------------编程问答-------------------- 对了,jmail组件的问题,jmail在哪里下载啊,在服务器上是不是要安装啊,还是只要引用jmail.dll这个就可以了? --------------------编程问答-------------------- jmail也不能使用163的,我那个邮箱是2000年注册的,用jmail也只是偶尔能发一两封,不是每封都能发出去。
--------------------编程问答-------------------- 用gmail的吧!!
很好用的!!
我就是用他做测试的!! --------------------编程问答-------------------- <add key="MailAccount" value="你的帐户"/>
<add key="MailPwd" value="密码" />
<add key="SMTP" value="smtp.gmail.com"/>
<add key="Port" value="587"/> --------------------编程问答--------------------
--------------------编程问答--------------------
static public void SendMail(MailAddressCollection sendTo, string subject, string body)
{
//.net smtp
System.Net.Mail.MailMessage mailmsg = new System.Net.Mail.MailMessage();
if (sendTo != null)
{
foreach (MailAddress address in sendTo)
mailmsg.To.Add(address);
}
MailAddress FromAddress = new MailAddress(accountName);
mailmsg.From = FromAddress;
mailmsg.Subject = subject;
mailmsg.IsBodyHtml = true;
mailmsg.BodyEncoding = System.Text.Encoding.UTF8;//邮件内容编码
mailmsg.Body = body;
System.Net.Mail.SmtpClient client = new SmtpClient();
//client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.Host = smtpServer;
client.Port = smtpPort;
client.Credentials = new System.Net.NetworkCredential(accountName, password);//用户名和密码
client.EnableSsl = true;
client.Send(mailmsg);
}
还一个 --------------------编程问答-------------------- http://www.svnhost.cn/Article/Detail-20.shtml 代码看看
补充:.NET技术 , ASP.NET