c# - 使用 C# 从 sendgrid 发送计划电子邮件

标签 c# email azure sendgrid bulk

我正在使用SendGrid用于在我的应用程序中发送电子邮件。现在我想每周向我的用户发送电子邮件。 sendgrid 中是否有可用的功能,如果有,那么我如何在 C# 中使用该 api

最佳答案

SendGrid 支持按计划发送电子邮件,只需额外一行代码。

使用SendGridMessage.SendAt属性(property)。它期望 UNIX 时间戳为 long

Gets or sets a unix timestamp allowing you to specify when you want your email to be sent from SendGrid. This is not necessary if you want the email to be sent at the time of your API request.

int sendAtUnixTime = new DateTimeOffset(sendOnUtcDateTime).ToUnixTimeSeconds();

var client = new SendGridClient("apiKey");
var from = new EmailAddress("fromEmailAddress", "fromName");
var to = new EmailAddress("toEmailAddress", "toName");
var msg = MailHelper.CreateSingleEmail(from, to, "subject", "", "bodyHtml");
msg.SendAt = sendAtUnixTime;                
var response = await client.SendEmailAsync(msg);

关于c# - 使用 C# 从 sendgrid 发送计划电子邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24751011/

相关文章:

c# - 使用正则表达式替换删除行

c# - 从 Dictionary<int, Fleas> 中高效获取 IReadOnlyDictionary<int, Animals>

c# - 获得文件或文件夹的所有权

PHP 引用可打印电子邮件和 Apple Mail App

powershell - 获取变量 Powershell 中资源组的位置值

javascript - 登录后如何在Logo下添加 "Username"

c# - Web 服务器正在发送重复的电子邮件

python - 在启动时不使用配置文件将 JDBC 驱动程序添加到 PySpark

Azure kubernetes - 如何使用 Azure API 管理来验证 kubernetes API?

email - 解析退回的电子邮件