4

I'm using office 365 mail Microsoft Graph API , trying to create new message following the Doc:

https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/user_post_messages

POST https://graph.microsoft.com/beta/me/messages
Content-type: application/json

{
    "subject":"Did you see last night's game?",
    "importance":"Low",
    "body":{
        "contentType":"HTML",
        "content":"They were <b>awesome</b>!"
    },
    "toRecipients":[
        {
            "emailAddress":{
                "address":"AdeleV@contoso.onmicrosoft.com"
            }
        }
    ]
}

{ OUTPUT:

"@odata.context":"https://graph.microsoft.com/beta/$metadata#users('ad787b4f-1fda-4523-8e48-ffedb7f4635f')/messages/$entity",
"@odata.etag":"W/\"CQAAABYAAAAmXr9SsE/UR4PcnTZcg7qWAAAFS12t\"",
"id":"AAMkAGRWAAAFSmKXAAA=",
"createdDateTime":"2017-12-23T07:29:57Z",
"lastModifiedDateTime":"2017-12-23T07:29:58Z",
"changeKey":"CQAAABYAAAAmXr9SsE/UR4PcnTZcg7qWAAAFS12t",
"categories":[

],
"receivedDateTime":"2017-12-23T07:29:58Z",
"sentDateTime":"2017-12-23T07:29:58Z",
"hasAttachments":false,
"internetMessageId":"<MWHPR130@MWHPR130.namprd13.prod.outlook.com>",
"subject":"Did you see last night's game?",
"bodyPreview":"They were awesome!",
"importance":"low",
"parentFolderId":"AAMkAGRWAAAAAAEPAAA=",
"conversationId":"AAQkAGRVYAsRJrRdc_mWNaxU=",
"conversationIndex":"AQHTe7/VAniOJVgCxEmtF1z6ZY1rFQ==",
"isDeliveryReceiptRequested":false,
"isReadReceiptRequested":false,
"isRead":true,

       "isDraft":true,

"webLink":"https://outlook.office365.com/owa/?ItemID=AAMkAGRWAAAFSmKXAAA%3D&exvsurl=1&viewmodel=ReadMessageItem",
"inferenceClassification":"focused",
"unsubscribeData":[

],

The output that I'm seeing is Draft message created in by inbox.

I tried to post with "isDraft":false , but the result unfortunately the same :(

Basically my purpose is "Restore" the original inbox messages , it means create them in Inbox without sending....I Did it with EWS , now trying to convert into graph api

So, Is Any option to create mail not as Draft ?

P.S: like in EWS https://msdn.microsoft.com/en-us/library/ms527503(v=exchg.10).aspx

Thanks a lot

VitalyT
  • 1,671
  • 3
  • 21
  • 49
  • Can you please make it more clear what you mean by creating a message? Because creating a message means you create a draft of your mail but don't send it to the recipient yet. Do you actually want to send the mail to the recipients? – AidaNow Feb 27 '18 at 15:41
  • @AidaNowzari: I had to remove my previous reply but I got the same question as you. In fact the OP wants to create a message that will be in the Inbox and which is not tagged as a draft. Without sending it. So... I think it will not be possible with Graph API – Nicolas R Feb 27 '18 at 15:46
  • @ Aida Nowzari , My purpose it "Restore" the original inbox messages , it means create them in Inbox without sending....I Did it with EWS , now trying to convert into graph – VitalyT Feb 27 '18 at 17:28

3 Answers3

8

The final solution as @David mentioned is via Extended properties:

acording to:

https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/api/singlevaluelegacyextendedproperty_post_singlevalueextendedproperties

and :

https://msdn.microsoft.com/en-us/office/office365/api/extended-properties-rest-operations

https://msdn.microsoft.com/en-us/library/ee218129(v=exchg.80).aspx

  "singleValueExtendedProperties": [
      {
         "id":"Integer 0x0E07",
         "value":"4"
      }
    ]
}
VitalyT
  • 1,671
  • 3
  • 21
  • 49
2

Yes. You have to set the message flags at creation time via property tag 0x0E07 (integer). From the EWS book with some mods - "According to MSDN, the MSGFLAG_UNSENT message flag is read-write ONLY before the message is first saved (http://msdn2.microsoft.com/en-us/library/ms527629.aspx). After that, the flag is read only. What this means is that if you are going to modify the message flags for a message, you must do it when you first call CreateItem (or the REST equivalent). You cannot clear this flag on an existing message."

  • @Davis Sterling, how this flag can be exposed in REST (how can i change it via api) ....? – VitalyT Feb 27 '18 at 17:24
  • The question is about doing it with Graph API, is there any equivalent of this property tag? Can't find anything similar in the doc – Nicolas R Feb 27 '18 at 22:59
  • PropertyTags can be accessed via ExtendedProperties in REST. The basic format for one representing a proptag is: this.PropertyId = string.Format("{0} {1}", type.ToString(), "0x" + this.Tag.ToString("X", CultureInfo.InvariantCulture)); Check out : https://msdn.microsoft.com/en-us/office/office365/api/extended-properties-rest-operations – David Sterling - MSFT Feb 28 '18 at 17:13
  • What you mentioned is It Outlook REST , I need Microsoft Graph REST API....is it possible ? – VitalyT Feb 28 '18 at 19:19
  • Can you build the Body is it " { "singleValueExtendedProperties": [ { "id":"Integer {8ECCC264-6880-4EBE-992F-8888D2EEAA1D} Id 0x0E07", "value":"MSGFLAG_SUBMIT" } ] }" – VitalyT Feb 28 '18 at 20:30
0

You can also look at the send a message on the fly option, which obviates the need to create a message somewhere then send it. We do this and don't end up with any drafts hanging around afterwards. See this for more details: https://msdn.microsoft.com/en-us/office/office365/api/mail-rest-operations?f=255&MSPPError=-2147217396#SendMessageOnTheFly

Steve Peschka
  • 1,015
  • 11
  • 25
  • @ Steve Peschka .. , sounds good , But to which destination it will send it , if would be a fake dest' ,sounds perfect ?? BUT I don't want really to send the messages to all recipients ..:( – VitalyT Mar 01 '18 at 18:24
  • Check out the documentation link I provided. You plug in whatever recipients you want, and that's where it goes. – Steve Peschka Mar 02 '18 at 18:35