好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

C#实现QQ邮箱发送邮件

闲着蛋疼。计划着改善公司的邮件服务。怎料公司网络封闭的太厉害了。我只能在家里利用开放点的网络来测试发送邮件;

利用qq邮箱发送到公司的企业邮箱上;

前提准备,登陆qq邮箱开启stmp服务。不开启的话没法通过代码登陆到你的邮箱;

查询腾讯qq邮箱的smtp主机地址为:smtp.qq测试数据  端口是587,或者465

?

using system;

using system.collections.generic;

using system.linq;

using system.text;

using system.net.mail;

namespace mail

{

   class program

   {

     static void main( string [] args)

     {

       //发件人地址

       mailaddress from = new mailaddress( "*********@qq测试数据" );

       mailmessage message = new mailmessage();

       message.body = "this is a test" ;

       message.isbodyhtml = true ;

       message.bodyencoding = system.text.encoding.utf8;

       //收件人地址

       message.to.add( "********bizip测试数据" );

       message.subject = "hello !" ;

       message.subjectencoding = system.text.encoding.utf8;

       message.from = from;

       smtpclient client = new smtpclient();

       client.enablessl = true ;

       client.host = "smtp.qq测试数据" ;

       client.port = 587;

       //邮箱账户和密码

       client.credentials = new system.net.networkcredential( "mailacount" , "password" );

       try

       {

         client.send(message);

       }

       catch (exception ex)

       {

         string mssage = ex.tostring();

       }    

     }

   }

}

很简单啊

vs2010测试通过!

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对服务器之家的支持。如果你想了解更多相关内容请查看下面相关链接

原文链接:https://blog.csdn.net/chenqiangdage/article/details/41530941

dy("nrwz");

查看更多关于C#实现QQ邮箱发送邮件的详细内容...

  阅读:45次