C# 用System.Net.Mail 发mail

    最近项目中有用到SMTP 发Mail ,   作个记录!   

using System.Net.Mail;
using System.Net;

---------------------     

                MailAddress MailFrom = new MailAddress(mailFrom);   --aaa@xxx.com
                MailAddress MailTo = new MailAddress(mailTo);          ---bbb@xxx.com
                MailAddress MailCC = new MailAddress(mailCC);         ---ccc@xxx.com
                MailMessage HtmlMailMessage = new MailMessage(MailFrom, MailTo);
                HtmlMailMessage.CC.Add(MailCC);
                HtmlMailMessage.Subject = mailSubject;
                HtmlMailMessage.Body = mailBody;
                HtmlMailMessage.IsBodyHtml = true;
                HtmlMailMessage.BodyEncoding = System.Text.Encoding.UTF8;
                HtmlMailMessage.Attachments.Add(new Attachment(mailAttachment));  -- 附件 地址
                SmtpClient mailSmtpClient = new SmtpClient(mailServer);  --mailServer SMTP 
                mailSmtpClient.Send(HtmlMailMessage);

posted on 2009-05-13 16:07  AndyCai  阅读(292)  评论(0编辑  收藏  举报

导航