using DotNetOpenMail;
using DotNetOpenMail.Logging;
using DotNetOpenMail.Encoding;
using DotNetOpenMail.Resources;
using DotNetOpenMail.SmtpAuth;
// /*创建一个邮件对象 */
EmailMessage emailMessage = new EmailMessage();
/*添加发件人的邮箱地址*/
emailMessage.FromAddress = new EmailAddress("cxy-yxc2003@163.com");
/*添加收件人的邮箱地址*/
emailMessage.AddToAddress(new EmailAddress("cxy-yxc2003@163.com"));
/*添加邮件主题*/
emailMessage.HeaderCharSet = System.Text.Encoding.GetEncoding("GB2312");
emailMessage.HeaderEncoding = EncodingType.Base64;
emailMessage.Subject = "我的测试Message";
/*设置邮件内容通过html附件*/
emailMessage.HtmlPart = new HtmlAttachment("<html><body><p>陈雪勇测试</p></body></html>");
emailMessage.HtmlPart.CharSet = System.Text.Encoding.GetEncoding("gb2312"); /*初始化smtp服务器 */
SmtpServer smtpServer = new SmtpServer("smtp.163.com");
/* 提供smtp服务器上有效的用户名和密码*/
smtpServer.SmtpAuthToken = new SmtpAuthToken("cxy-yxc2003@163.com", "831215");
/*设置内容类型*/
emailMessage.ContentType = "TEXT/HTML";
/*发送邮件*/
emailMessage.Send(smtpServer);
Response.Write(" Email Successfully Sent");