发送邮件


public void SendEmail()
{
    var path = Path.Combine(Server.MapPath("../"), "Content\\template\\email\\eCalendar.html");
    var template = System.IO.File.ReadAllText(path);

    var body = template.Replace("{{Name}}", "")
                        .Replace("{{Type}}", "")
                        .Replace("{{Description}}", "")
                        .Replace("{{Subject}}", "");

    string smtpServer = "Lamb.corning.com";
    int smtpPort = 25;
    SmtpClient smtp = new SmtpClient(smtpServer, smtpPort);
    Email.DefaultSender = new SmtpSender(smtp);
    var result = Email.From("MTE OA(DO NOT REPLY) <noreply@corning.com>")
                        .To("zhangs49@corning.com")
                        //.CC("zhangs49@corning.com")
                        .Subject("邮件主题")
                        .Body(body, true)
                        .Send();
}

posted @ 2024-08-08 13:42  暖暖De幸福  阅读(3)  评论(0编辑  收藏  举报