日期:2014-05-17  浏览次数:20923 次

.net jmail组件发送邮件报错 跪求高手 送分
public static bool send(string strMto, string strMfrom, string strFname, string strSubject, string strHtml)
{
jmail.Message jmail = new jmail.Message();
string subject = strSubject;
string body = strHtml;
string fromemail = strMfrom;
jmail.FromName = strFname;//发送人姓名
string toemail = strMto;
//silent属性:如果设置为true,jmail不会抛出例外错误. jmail. send( () 会根据操作结果返回true或false
jmail.Silent = false;
//jmail创建的日志,前提loging属性设置为true
jmail.Logging = true;
//字符集,缺省为"us-ascii"
jmail.Charset = "gb2312";
//jmail.ContentTransferEncoding = "base64";
//jmail.Encoding = "base64";
//信件的contentype. 缺省是"text/plain") : 字符串如果你以html格式发送邮件, 改为"text/html"即可。
jmail.ContentType = "text/html";
//添加收件人
jmail.AddRecipient(toemail, "", "");
jmail.From = fromemail;
//发件人邮件用户名
jmail.MailServerUserName = "******";
//发件人邮件密码
jmail.MailServerPassWord = "******";
//设置邮件标题
jmail.Subject = subject;
//邮件添加附件,(多附件的话,可以再加一条jmail.addattachment( "c:\\test.jpg",true,null);)就可以搞定了。〔注〕:加了附件,讲把上面的jmail.contenttype="text/html";删掉。否则会在邮件里出现乱码。
//jmail.AddAttachment( "c:\\test.jpg",true,null);
//邮件内容
jmail.Body = body;
//jmail.Silent = true;
//jmail发送的方法
bool result = jmail.Send("smtp.qq.com", false);
jmail.Close();
return result;
}
代码如上边错误代码 0x8000ffff

bool result = jmail.Send("smtp.qq.com", false);这句报错

请不要拿网上的代码复制粘贴 谢谢。

提示是:The message was undeliverable. All servers failed to receive the message

------最佳解决方案--------------------
试试这个,绝对好用,我就这么用的
 public static void SendEmail(string from, string to, string cc, string subject, string body, string attachment)
    {
        System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage(from, to, subject, body);
        mail.CC.Add(new MailAddress(cc));
        mail.Attachments.Add(new Attachment(attachment));
        mail.IsBodyHtml = false;

        System.Net.Mail.SmtpClient send = new System.Net.Mail.SmtpClient("smtp.gmail.com");
        send.Port = 587;// gmail;
        send.EnableSsl = true;
        send.UseDefaultCredentials = false;
        send.Credentials = new NetworkCredential("username", "password");
        send.Send(mail);
    }


------其他解决方案--------------------
是不是想破解邮箱,发送邮箱多了,服务器当然会关闭了。
------其他解决方案--------------------
没有啊 我用了163  sina  qq的 都不行 一封都发不出去
------其他解决方案--------------------
。。。顶下 没人帮忙啊
------其他解决方案--------------------