Skip to content

Instantly share code, notes, and snippets.

@jzwang-dev
Created February 16, 2021 12:42
Show Gist options
  • Save jzwang-dev/56721f7cd888c2da839505851ea23d33 to your computer and use it in GitHub Desktop.
Save jzwang-dev/56721f7cd888c2da839505851ea23d33 to your computer and use it in GitHub Desktop.
[HttpPost]
public ActionResult SendOrderEmail()
{
var order = Models.OrderUtil.GetTestOrder();
string subject = "測試主旨";
ViewBag.remark = "寄送時間:" + DateTime.Now;
string body = JZLib.JZUtil.RenderViewToString(ControllerContext, "_OrderEmailTemplate", order);
using (SmtpClient smtp = new SmtpClient("your.smtp.server"))
{
smtp.Send(new MailMessage("noreply@jzcorp.com", order.customer_email)
{
Subject = subject,
Body = body,
IsBodyHtml = true
});
}
return View("MailSent");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment