使用的是JMail4.3专业版来发送邮件
1.先安装JMail
2.把生成的dll拷贝到system32下,然后regsvr32 jmail.dll
3.代码如下:
       jmail.MessageClass mail = new jmail.MessageClass();
       mail.ISOEncodeHeaders = false;
       mail.ContentType = "text/html";
       mail.Charset = "gb2312";
       RecipientClass r = new RecipientClass();
       r.New("mapengfei", "[email protected]", sbyte.MaxValue);
       mail.Recipients.Add(r);
       mail.Subject = "主题";
       mail.Body = "内容";
       mail.Priority = 1;
       mail.From = "[email protected]";
       mail.FromName = "马鹏飞";
       mail.ReturnReceipt = true;
       mail.MailServerUserName = "edwindoctornma";
       mail.MailServerPassWord = "*****";
       mail.HTMLBody = "<b>fdsafdsa</b>";
       //mail.Silent = true;
       mail.Logging = true;
       try
       {
           //mail.Send("edwindoctornma:***@gmail.com:587",false);//存在异常
           mail.Send("smtp.gmail.com", false);//存在异常
        }
        catch (Exception ex)
        {
            mail.Close();
        }
///////异常内容如下:
The message was undeliverable. All servers failed to receive the message
从网上查了很多资料,也没有解决,mail.Send("smtp.163.com",false);mail.Send("smtp.sina.com",false);等都出现同样的异常信息ComException
请高手指教

解决方案 »

  1.   

    你用的什么端口,好像在gmail里可以设置。
    是否有本地防火墙.block了端口参考:
    http://www.developerfusion.com/forum/thread/32112/
      

  2.   

    jmail里设置的是pop3的,不用设置smtp,没有防火墙和杀毒软件
      

  3.   

    根据下面的文章
    gmail的smtp端口是465 or 587 
    并且TLS/SSL required as: yes 
    http://techblissonline.com/gmail-smtp/
      

  4.   

    还有啊acccount name应该是
    Configure Gmail SMTP user name as: your full Gmail address (including @gmail.com)
      

  5.   

    你们试一试,看能不能发,用System.Net.Mail下的MailMessage和SmtpClient可以发给
    [email protected],现在换成JMail组件就不行了。。网上很多都遇到了这个异常,回答的含糊其辞。
      

  6.   

    SmtpClient client = new SmtpClient();
                MailMessage message = new MailMessage();
     
                client.Credentials = new NetworkCredential(@"域名", @"密码");
                client.Host = "邮箱服务器";
                message.From = new MailAddress(@"发送者邮件地址");
                message.To.Add("接受者邮件地址");
               
     
                message.Subject = "Subject";//标题
                message.Body = "Body";//内容
                message.IsBodyHtml = true;
                message.BodyEncoding = Encoding.UTF8;
     
                
                    client.Send(message);
     
      

  7.   

    帮助上写的是
    带凭证的
    mail.Send("username:[email protected]:端口号",false);
      

  8.   


    这再加上端口号程序就对了,现在用的是JMail组件,它可以加密邮件,集群发邮件,个性邮件,不知道那个异常信息到底该怎么解决他们都说可能是邮件服务器拒绝像JMail这类中继邮件中间组件了,所以发送不成功。但我试了126.163等,都不成功郁闷
      

  9.   

    如果要求的功能不复杂的话,自己写一个邮件发送组件就是了。
    前段时间,我用Delphi自带的邮件发送类,写的邮件发送程序,很好用的。