【发布时间】:2016-08-04 02:02:18
【问题描述】:
这是我的代码
public static void sendEmail(string sendto, string subject, string template, Object model)
{
SendGridAPIClient sg = new SendGridAPIClient(ConfigurationManager.AppSettings["SendGridAPIKey"]);
Email from = new Email(ConfigurationManager.AppSettings["EmailSender"]);
Email to = new Email(sendto);
var templateFolder = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "EmailTemplates");
var tpl = File.OpenText(templateFolder + "\\" + template).ReadToEnd();
string textbody = Engine.Razor.RunCompile(tpl, template, null, model);
Content content = new Content("text/plain", textbody);
Mail mail = new Mail(from, subject, to, content);
dynamic response = sg.client.mail.send.post(requestBody: mail.Get());
}
这个函数在很多地方被调用。如何在不阻塞调用此函数的多个位置的情况下使此函数运行?
【问题讨论】:
标签: asp.net-mvc sendgrid