zoukankan      html  css  js  c++  java
  • 【转】c# 发送email,正文支持html格式,包含附件

    代码
    转自:http://www.cnblogs.com/phcis/archive/2010/03/02/1676577.html
    string v_smtpAddress ="smtp.xxx.com";//smtp地址,如smtp.163.com
    string v_sendMailUserName = "userName";//发送邮件使用的用户名
    string v_sendMailPassword = "userPwd";//发送邮件使用的密码
    string v_sendMailAddress ="phcis@163.com";//发送邮件的mail地址
    string v_receiveMailAddress ="phcis@163.com";//接收邮件的mail地址
    string v_mailSubject = "邮件主题";//邮件主题
    SmtpClient smtp = new SmtpClient(v_smtpAddress);
    smtp.Credentials
    = new System.Net.NetworkCredential(v_sendMailUserName, v_sendMailPassword);
    MailMessage mes
    = new MailMessage();
    mes.From
    = new MailAddress(v_sendMailAddress);
    mes.To.Add(v_receiveMailAddress);

    mes.Subject
    = v_mailSubject;
    mes.Body
    = TextArea1.Value;
    mes.IsBodyHtml
    = true;//使用是否html格式
    //增加附件
    System.Net.Mail.Attachment mailAttach_1 = new Attachment(@"d:\b.txt");
    mes.Attachments.Add(mailAttach_1);

    smtp.Send(mes);
    mailAttach_1.Dispose();
    //释放由附件占用的资源
  • 相关阅读:
    IE8、IE9解决浏览器跨域。
    英语写作-Introduction
    qt添加图标
    Qt 编译错误 :cannot find file .pro
    python
    数据集
    基金
    visio2010求交操作
    书籍网站
    ROS安装xtion
  • 原文地址:https://www.cnblogs.com/ustcyc/p/1893419.html
Copyright © 2011-2022 走看看