通过smtp直接发送邮件
/// <param name="fromEmail">发件人的邮箱</param>
/// <param name="toEmail">收件人的邮箱 多个用 “,”分隔</param>
/// <param name="ccEmail">抄送 多个用 “,”分隔</param>
/// <param name="bccEmail">密送 多个用 “,”分隔</param>
/// <param name="subject">邮件主题</param>
/// <param name="body">邮件正文</param>
/// <param name="smtpAddress">邮件发送服务器</param>
/// <param name="account">邮件发送账号</param>
/// <param name="pwd">邮件发送密码</param>
/// <returns></returns>
public static bool SendMailBySMTP(string body)
{
System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage("自己邮箱@yingu.com", "自己邮箱@yingu.com");
//mail.s
mail.SubjectEncoding = Encoding.UTF8;
mail.Subject = "债权数据匹配数据获取异常";
mail.IsBodyHtml = true; //是否允许内容为 HTML 格式
mail.BodyEncoding = Encoding.UTF8;
mail.Body = body;
SmtpClient smtp = new SmtpClient("smtp.qiye.163.com");
smtp.Credentials = new NetworkCredential("自己邮箱@yingu.com", "邮箱密码"); //SMTP 验证
//smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
bool rr = true;
try
{
smtp.Send(mail);
}
catch (Exception ex)
{
rr = false;
}
mail.Attachments.Dispose(); //邮件发送完毕,释放对附件的锁定
return rr;
}
上一篇: 遮罩层 + Iframe实现界面自动显示的示例代码
下一篇: 四川西昌特产有哪些,四川人快来介绍一下