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;
}
代码如上边错误代码 0x8000ffffbool result = jmail.Send("smtp.qq.com", false);这句报错请不要拿网上的代码复制粘贴 谢谢。提示是:The message was undeliverable. All servers failed to receive the message

解决方案 »

  1.   

    没有啊 我用了163  sina  qq的 都不行 一封都发不出去
      

  2.   

    试试这个,绝对好用,我就这么用的
     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);
        }
      

  3.   

    public static bool sendEmail(string EmailAddress, string RecipientName,string PGPKey,string strHtml,string MailTitle)
    {
    bool isNo = false;
    jmail.Message jmessage = new jmail.MessageClass(); jmessage.Charset = "GB2312";

    jmessage.From = "[email protected]";//发送邮件人的邮箱

    jmessage.FromName = "第一英才";//发送邮件人的用户名

    jmessage.ReplyTo = "[email protected]";//跟上边一样的

    jmessage.ContentType = "text/html";

    jmessage.Charset = "GB2312";

    jmessage.ContentTransferEncoding = "base64";

                jmessage.Encoding = "base64";

    jmessage.Subject = MailTitle;//标题

    jmessage.AddRecipient(EmailAddress, RecipientName, PGPKey);//收件人

    jmessage.Body = strHtml;//内容

    jmessage.MailServerUserName = "[email protected]";//发件人用户名

    jmessage.MailServerPassWord = "123456a";//发件人用户密码

    if(jmessage.Send("smtp.qq.com", false))// smtp
    {
    isNo = true;
    }else
    {
    isNo = true;
    }

    //Response.Write("email   sent   successfully!");

    jmessage.Close();//注意这里,一定要关闭连接   否则邮件发不出去
    return isNo;   
    }
      

  4.   

    代码基本是没错的,你的机器支持jmail吗,还有做好不要用qq的邮箱。我的用qq就不可,用163就没问题,不知为什么,你要是qq的弄好了给我说声啊