static void Main(string[] args) { //普通测试 SmtpMailClient client = new SmtpMailClient("smtp.163.com", 25, true, "XXX", "XXX"); client.Timeout = 18000; MailMessage msg = new MailMessage(); msg.From = new MailAccount("*****@*****.**", "janky"); msg.AddTo(new MailAccount("*****@*****.**", "测试1")); msg.AddTo(new MailAccount("*****@*****.**")); msg.AddCC(new MailAccount("*****@*****.**")); //msg.AddCC(new MailAccount("*****@*****.**")); msg.MailContent = "<p>IHU 发信IP因发送垃圾邮件或存在异常的连接行为,被暂时挂起。请检测发信IP在历史上的发信情况和发信程序是否存在异常;</p><a href='http://163.com'>163 邮箱</a>"; msg.Subject = "测试"; msg.IsHtml = true; client.Send(msg); //附件测试 client = new SmtpMailClient("smtp.163.com", 25, true, "XXX", "XXX"); client.Timeout = 18000; msg = new MailMessage(); msg.From = new MailAccount("*****@*****.**", "janky"); msg.AddTo(new MailAccount("*****@*****.**", "测试1")); msg.AddTo(new MailAccount("*****@*****.**")); msg.AddCC(new MailAccount("*****@*****.**")); msg.MailContent = "<img src='cid:test1234' /><p>IHU 发信IP因发送垃圾邮件或存在异常的连接行为,被暂时挂起。请检测发信IP在历史上的发信情况和发信程序是否存在异常;</p><a href='http://163.com'>163 邮箱</a>"; msg.Subject = "测试"; msg.IsHtml = true; msg.AddAttachment(@"c:\test\test.txt"); msg.AddAttachment(@"c:\test\taiwan.jpg", "test1234"); //这里是content-id msg.AddAttachment(@"c:\test\filechktool.rar"); client.SendAsync(msg); //ssl 测试 SmtpServerInfo info = new SmtpServerInfo("smtp.gmail.com", 465, true, "XXX", "janky,.XXX"); info.EnableSsl = true; client = new SmtpMailClient(info); client.Timeout = 18000; msg = new MailMessage(); msg.From = new MailAccount("*****@*****.**", "系统"); msg.AddTo(new MailAccount("*****@*****.**", "测试1")); msg.AddTo(new MailAccount("*****@*****.**")); msg.AddCC(new MailAccount("*****@*****.**")); msg.MailContent = "<p>IHU 发信IP因发送垃圾邮件或存在异常的连接行为,被暂时挂起。请检测发信IP在历史上的发信情况和发信程序是否存在异常;</p><a href='http://163.com'>163 邮箱</a>"; msg.Subject = "测试"; msg.IsHtml = true; client.Send(msg); Console.ReadKey(); }