在app.config或web.config中配置邮件发送参数

 

<system.net>
    <mailSettings>
      <smtp deliveryMethod="Network">
        <network host="smtp.host_name.com" userName="mail_address(e.g.:zhansan@163.com)" password="mail_password" port="25"/>
      </smtp>
    </mailSettings>
  </system.net>

 示例代码:

SmtpClient client = new SmtpClient();
client.Send(new MailMessage("zhansan@163.com"  //from
, "superwcg@gmail.com"     //to
,"您好,这是测试邮件"          //subject
, "这是邮件内容"                //body
));

posted @ 2010-12-18 15:21  庚武  Views(330)  Comments(0Edit  收藏  举报