Add support for not saving item in SentItems when sending Draft

Add support for not saving item in SentItems when sending Draft
5

Upvotes

Upvote

 Dec 06 2021
2 Comments (2 New)
New

Regarding send emails with the Outlook Mail Graph API, there are two options for sending an email;

 

  1. /sendMail. Send it with a single request. For smaller emails.
  2. /send. Send it using a draft. Needed in order to use upload session for large attachments.

 

For single requests (/sendMail), it’s possible to specify not to save email in sentitems;

 

https://docs.microsoft.com/en-us/graph/api/user-sendmail?view=graph-rest-1.0&tabs=http

 

The same does not apply to /send when sending drafts. So, after sending the mail, I have to delete the message from sentitems myself.

 

Here comes the trouble, because when is it ok to do so? I fail to see how I can tell.

 

If I do it straight away I might get 404. If I wait a bit, I might not get 404, and everything looks great, but instead some of the mails do not get sent at all (tested to both Exchange and Gmail recipient). So it seems the API uses the message to actually send it later on, but then it’s deleted and it cannot send it.

 

My suggestion would be to add to the API, some optional options when calling /send. These options could basically be like for /sendMail;

 

https://docs.microsoft.com/en-us/graph/api/message-send?view=graph-rest-1.0&tabs=http

 

POST /v1.0/me/messages/<id>/send HTTP/1.1

Host: graph.microsoft.com

Accept: */*

Accept-Encoding:

Content-Length: 35

Content-Encoding: identity

Authorization: Bearer <token>

Prefer: IdType="ImmutableId"

 

{

  "saveToSentItems": "false"

}

 

Basically this would just delete the draft once mail has been delivered to receiving mail server, instead of move it to sentitems. Exactly like /send appears to do. Consistent and you’ll save server side work and a number of requests trying to delete the messages, when users do not want sentitems to pile up.

Comments
Copper Contributor

This is actually more than just a suggestion, because currently I cannot delete from sentitems since I do not have a state. This means the headless mailbox gets filled with sentitems, the customers do not want. Not ideal, so hoping for swift resolution.

Copper Contributor

It would be good, if this also works for /forward /reply /replyAll and the respective drafts: /createForward, /createReply /createReplyAll