您可以使用扩展属性来实现电子邮件的延迟发送。这些可以使用“singleValueExtendedProperties”属性在 Graph API 请求负载上进行设置。
要使用的属性是PidTag延迟发送时间 https://msdn.microsoft.com/en-us/library/ee203834(v=exchg.80).aspx它的 ID 为 0x3FEF,类型为 SystemTime。
The “singleValueExtendedProperties”的 id 属性 https://learn.microsoft.com/en-us/graph/api/resources/extended-properties-overview?view=graph-rest-1.0根据您设置的属性采用不同的格式。
对于延迟发送时间,您将使用SystemTime 0x3FEF
.
使用 HTTP JSON POST 负载的示例:
{
"message": {
"subject": "Meet for lunch?",
"body": {
"contentType": "Text",
"content": "The new cafeteria is open."
},
"toRecipients": [
{
"emailAddress": {
"address": "[email protected] /cdn-cgi/l/email-protection"
}
}
],
"singleValueExtendedProperties":
[
{
"id":"SystemTime 0x3FEF",
"value":"2019-01-29T20:00:00"
}
]
}
}
使用 Microsoft Graph API 客户端库的示例:
var client = /* Create and configure GraphServiceClient */;
var msg = new Message();
msg.ToRecipients = List<Recipient>();
msg.ToRecipients.Add(new Recipient() {
EmailAddress = new EmailAddress() { Address ="[email protected] /cdn-cgi/l/email-protection" }
};
msg.Subject = "Meet for lunch?";
msg.Body = new ItemBody()
{
Content = "The new cafeteria is open.",
ContentType = BodyType.Text,
};
msg.SingleValueExtendedProperties = new MessageSingleValueExtendedPropertiesCollectionPage();
msg.SingleValueExtendedProperties.Add(new SingleValueLegacyExtendedProperty()
{
Id = "SystemTime 0x3FEF",
Value = DateTime.UtcNow.AddMinutes(5).ToString("o")
});
await client.Me.SendMail(msg, true).Request().PostAsync();