稍后发送电子邮件

时间:2018-02-08 22:46:35

标签: microsoft-graph

我想知道/v1.0/me/sendMail是否有能力延迟发送电子邮件。在Outlook客户端中,您可以指定希望在以后的日期和时间发送电子邮件。我已经窥探,看看是否有可以在消息对象上设置的属性来表明这一点。

有没有人找到办法让这个工作?当然,我可以在我的软件中实现一些处理延迟发送的东西,但是如果它已经存在,为什么要重新创建呢。

2 个答案:

答案 0 :(得分:1)

https://gallery.technet.microsoft.com/office/Send-Emails-until-a-9cee20cf

在创建项目时设置延迟发送时间扩展道具。

答案 1 :(得分:0)

您可以使用扩展属性来延迟发送电子邮件。可以使用“ singleValueExtendedProperties”属性在Graph API请求有效负载上进行设置。

要使用的属性是PidTagDeferredSendTime,其ID为0x3FEF,类型为SystemTime。

id attribute of "singleValueExtendedProperties"采用不同的格式,具体取决于您设置的属性。

对于延迟的发送时间,您可以使用SystemTime 0x3FEF

使用HTTP JSON POST有效负载的示例:

{
  "message": {
    "subject": "Meet for lunch?",
    "body": {
      "contentType": "Text",
      "content": "The new cafeteria is open."
    },
    "toRecipients": [
      {
        "emailAddress": {
          "address": "bob@contoso.com"
        }
      }
    ],
    "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 ="bob@contoso.com" }
};

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();
相关问题