好吧,这很奇怪!
我有一个代码,可以使用 sendgrid api (Sendgrid 8.0.5) 向人们发送预定的电子邮件。它在我的本地系统上运行良好,但在 Azure(在应用程序服务上)它只是忽略了 SendAt 时间。
public async Task SendVotingTimeIsUpEmail(model)
{
sg = new SendGridAPIClient(SettingsHelper.Instance.EmailApiKey, "https://api.sendgrid.com");
Email from = new Email(SettingsHelper.Instance.Sender);
Email to = new Email(user.Email);
Content content = new Content("text/html", "content");
Mail mailSt = new Mail(from, "subject", to, content) { TemplateId = SettingsHelper.Instance.VotingTimeIsUpTemplateId };
var datetimeOffset = new DateTimeOffset(model.ExpirationDate.Value, TimeSpan.Zero);
mailSt.SendAt = datetimeOffset.ToUnixTimeSeconds();
System.Diagnostics.Trace.TraceInformation($"Send at {mailSt.SendAt}");
dynamic response = await sg.client.mail.send.post(requestBody: mailSt.Get());
}
我在 5 分钟前尝试过。这是我在日志中的内容:
发送至 1480594002(格林威治标准时间 2016 年 12 月 1 日星期四 12:06:42)
而今天是 11 月 30 日,所以我不希望它现在发送消息。但我刚刚在我的电子邮件中收到了它。
任何想法?