我这里只是试了一下发mail的功能,感觉.net自带的发mail是比较全的,还是直接上我的code
参数文章:System.Net.Mail 发送邮件 SMTP协议
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Net.Mail; namespace MailSend { public class MainSend { public static void SendMail() { MailMessage mail = new MailMessage(); //屏蔽垃圾箱的功能 mail.Headers.Add("X-Priority", "3"); mail.Headers.Add("X-MSMail-Priority", "Normal"); mail.Headers.Add("X-Mailer", "Microsoft Outlook Express 6.00.2900.2869"); mail.Headers.Add("X-MimeOLE", "Produced By Microsoft MimeOLE V6.00.2900.2869"); mail.Subject = "測試郵箱功能"; mail.From = new MailAddress("XXX@XXX.com"); //mail.To.Add("GuoliXia@wistronits.com"); mail.To.Add("XXX@XXX.com"); mail.CC.Add("XXXX@XXX.com"); mail.Bcc.Add("XXXX@XXX.com"); mail.Body = "<p>hello</p><table><tr><td>1234</td></tr></table>"; mail.Attachments.Add(new Attachment(@"C:\Report\XXXXX_20140214.xls")); mail.Attachments.Add(new Attachment(@"C:\Report\XXXXX_20140213.xls")); mail.BodyEncoding = System.Text.Encoding.UTF8; mail.IsBodyHtml = true; mail.Priority = MailPriority.High; SmtpClient client = new SmtpClient(); client.Host = "XXXXXX"; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.EnableSsl = true; client.Credentials = new System.Net.NetworkCredential("XXXXX", "!XXXXX"); client.Send(mail); } } }
2.调用
MailSend.MainSend.SendMail();
还是比较简单的,一些地址被我用xxx替代了