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

 

<system.net>

    <mailSettings>

      <smtp deliveryMethod="Network">

        <network host="smtp.host_name.com" userName="mail_address(e.g.:[email protected])" password="mail_password" port="25"/>

      </smtp>

    </mailSettings>

  </system.net>



 示例代码:

SmtpClient client = new SmtpClient();

client.Send(new MailMessage("[email protected]"  //from

, "[email protected]"     //to

,"您好,这是测试邮件"          //subject

, "这是邮件内容"                //body

));

你可能感兴趣的:(config)