好的,这很奇怪!
我有一个代码,使用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 GMT)
今天是11月30日,所以我不希望它现在发送消息。但我刚在电子邮件中收到了它。
任何想法?