How to find parent_message_id of reply message in graph api - microsoft-graph-api

I mean that Incoming reply mail is which mail reply,
To find this I want parent_message_id by using this I'm easily find parent_mail.
below code is respone of reply mail.
I want to find It's parent mail means below mail is which mail reply
To find parent mail I want parent_mail_id How can I find this ?
{
"#odata.etag": "W/\"CQAAABYAAABexZ50mSS0TKajvW/Uc3jZAAAhk64J\"",
"id": "AQMkADAwATM3ZmYAZS01OWRhLTM5MjgtMDACLTAw....",
"createdDateTime": "2023-02-02T08:39:59Z",
"lastModifiedDateTime": "2023-02-02T08:40:01Z",
"changeKey": "CQAAABYAAABexZ50mSS0TKajvW/Uc3jZAAAhk64J",
"categories": [],
"receivedDateTime": "2023-02-02T08:40:00Z",
"sentDateTime": "2023-02-02T08:39:46Z",
"hasAttachments": false,
"internetMessageId": "<CAJjLavQHv0SDMHxiKpRUCE=NU9X4AnL2QfPKjLJMbPeudvNP-A#mail.gmail.com>",
"subject": "Re: Meet for lunch 12:40?",
"bodyPreview": "12:40 reply mail\r\n\r\nOn Thu, 2 Feb 2023 at 13:06, ** <****#outlook.com> wrote:\r\nThe new cafeteria is open.",
"importance": "normal",
"parentFolderId": "AQMkADAwATM3ZmYAZS01OWRhLTM5MjgtMDACLTAwCgAuAAADNqdil3J7jU_HbfQfdBJYbQEAXsWedJkktEymo71v1HN42QAAAgEMAAAA",
"conversationId": "AQQkADAwATM3ZmYAZS01OWRhLTM5MjgtMDACLTAwCgAQAAo6snnrhhJOv0qLJ4Io1Fo=",
"conversationIndex": "AQHZNtkeCjqyeeuGEk6/SosngijUWq67VhwA",
"isDeliveryReceiptRequested": null,
"isReadReceiptRequested": false,
"isRead": false,
"isDraft": false,
"webLink": "https://outlook.live.com/owa/?ItemID=AQMkADAwATM3ZmYAZS01OWRhLTM5MjgtMDACLTAwCgBGAAADNqdil3J7jU%2BHbfQfdBJYbQcAXsWedJkktEymo71v1HN42QAAAgEMAAAAXsWedJkktEymo71v1HN42QAAACGV0fkAAAA%3D&exvsurl=1&viewmodel=ReadMessageItem",
"inferenceClassification": "focused",
"body": {
"contentType": "html",
"content": "<html><head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"></head><body><div dir=\"ltr\">12:40 reply mail </div><br><div class=\"gmail_quote\"><div dir=\"ltr\" class=\"gmail_attr\">On Thu, 2 Feb 2023 at 13:06, ** <***#outlook.com> wrote:<br></div><blockquote class=\"gmail_quote\" style=\"margin:0px 0px 0px 0.8ex; border-left:1px solid rgb(204,204,204); padding-left:1ex\">The new cafeteria is open.</blockquote></div></body></html>"
},
"sender": {
"emailAddress": {
"name": "****",
"address": "***#gmail.com"
}
},
"from": {
"emailAddress": {
"name": "****",
"address": "****"
}
},
"toRecipients": [
{
"emailAddress": {
"name": "***",
"address": "****#outlook.com"
}
}
],
"ccRecipients": [],
"bccRecipients": [],
"replyTo": [],
"flag": {
"flagStatus": "notFlagged"
}
},
I've send mail by using /sendMail graph api and for this sent mail I've reply mail by using other platform(ex:gmail) ,So how can I know incoming message parent message I mean which message reply is it

You need to take the conversationId from your message and filter messages by conversationId
GET https://graph.microsoft.com/v1.0/me/messages?$filter=conversationId eq '{conversation_id}'
Then order the messages by conversation index. The property conversationIndex does not support filtering on the server, so you need to order messages on the client as a string.
From ordered messages you are able to get the parent message.

There Isn't Any way to find parent_id by using reply mail response , In response provide parent_folderId but It Isn't useful to find parent_id
There Is one way to find parent_id If parent and reply messages have same conversation-id but Isn't then It cannot be possible to find the correct parent message

Related

Graph API calendar endpoint doesn't support sending Adaptive card as attachment

We are using https://graph.microsoft.com/v1.0/me/calendar/events for creating Calendar events. What we are trying to achieve additionally is to send an adaptive card as attachment. We are using below code as POST body
{
"subject": null,
"body": {
"contentType": "html",
"content": "<attachment id=\"74d20c7f34aa4a7fb74e2b30004247c5\"></attachment>"
},
"attachments": [
{
"id": "74d20c7f34aa4a7fb74e2b30004247c5",
"contentType": "application/vnd.microsoft.card.adaptive",
"contentUrl": null,
"content": "{\"$schema\":\"http://adaptivecards.io/schemas/adaptive-card.json\",\"version\":\"1.5\",\"type\":\"AdaptiveCard\",\"body\":[{\"type\":\"Container\",\"style\":\"emphasis\",\"items\":[{\"type\":\"TextBlock\",\"text\":\"TheEYorganizationtodayannouncesthedetailsofthe52womenfounders\",\"wrap\":true},{\"type\":\"ColumnSet\",\"columns\":[{\"style\":\"default\",\"width\":\"stretch\",\"items\":[{\"type\":\"ColumnSet\",\"columns\":[{\"items\":[{\"type\":\"Image\",\"width\":\"200px\",\"url\":\"https://tse3.mm.bing.net/th/id/OIP._awI5wQIVTy1k8QdHtpSWQHaEK?w=292&h=180&c=7&r=0&o=5&dpr=1.3&pid=1.7\"}],\"type\":\"Column\",\"width\":\"auto\"},{\"items\":[{\"type\":\"TextBlock\",\"size\":\"Medium\",\"weight\":\"Bolder\",\"text\":\"SomeText\",\"wrap\":true},{\"type\":\"TextBlock\",\"size\":\"Medium\",\"weight\":\"Bolder\",\"text\":\"[https://adaptivecards.io](https://adaptivecards.io)\",\"wrap\":true}],\"type\":\"Column\",\"width\":\"auto\"}]}],\"minHeight\":\"100px\",\"type\":\"Column\"}]}]}]}",
"name": null,
"thumbnailUrl": null
}
],
"start": {
"dateTime": "2022-11-18T12:00:00",
"timeZone": "Pacific Standard Time"
},
"end": {
"dateTime": "2022-11-18T12:30:00",
"timeZone": "Pacific Standard Time"
},
"location": {
"displayName": "Harry's Bar"
},
"attendees": [
{
"emailAddress": {
"address": "xero.01234#contoso.com",
"name": "Orex"
},
"type": "required"
}
],
"isOnlineMeeting": true,
"onlineMeetingProvider": "teamsForBusiness"}
Using above body, I am getting below error
{
"error": {
"code": "UnableToDeserializePostBody",
"message": "were unable to deserialize "
}}
As I understand this has something to do with the JSON I am passing as content inside attachment, I want to know if calendar invites endpoint supports adaptive card or not or is there any way, we can send adaptive card (using .NET SDK) to mail or events in outlook
Thanks, in advance
You can send actionable messages via emails only, see Supported scenarios for more information.

Unable to retrieve event details using Microsoft Graph API 1.0

Has anyone got Microsoft Graph API working for EventMessage? i.e reading email content of EventMessage using Graph API.
Looks like it has actionable card and graph API 1.0 is not able to read it.
Provided delegate access to user for a room resource.
On event creation for that room, mail is received by the delegated user in inbox. The mail type is eventMessage ("#odata.type": "#microsoft.graph.eventMessage").
On fetching the mail through GraphAPI v1.0, the event values are not visible in the response.
Also on setting the Expand property for the mail in graph API as per docs, results in below error.
{ "error": {
"code": "BadRequest",
"message": "Parsing Select and Expand failed.",
"innerError": {
"request-id": "310bbcce-bdd8-4cb6-890c-035243a5ab6d",
"date": "2020-01-21T09:18:10"
}
}
}
I'm unable to repro your issue. The Microsoft Graph API returns details for event messages. Can you provide repro steps, request/response capture, and the values that you'd expect to see?
I used v1.0/me/messagesto get all of the messages to find an eventMessage. I then perform the following to get details on the eventMessage:
GET https://graph.microsoft.com/v1.0/me/messages/{messagedId}
Response body:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('d09-94-498-a9777d4b')/messages/$entity",
"#odata.type": "#microsoft.graph.eventMessage",
"#odata.etag": "W/\"DAA2pU9s\"",
"id": "AAMkADEzOTExYjJkAAA=",
"createdDateTime": "2020-01-24T14:47:24Z",
"lastModifiedDateTime": "2020-01-24T21:08:07Z",
"changeKey": "DApU9s",
"categories": [],
"receivedDateTime": "2020-01-24T14:47:25Z",
"sentDateTime": "2020-01-24T14:47:11Z",
"hasAttachments": false,
"internetMessageId": "<AM5P3M#A38.EURPRD83.prod.outlook.com>",
"subject": "Accepted: Microsoft Graph DevX Roadmap",
"bodyPreview": "",
"importance": "normal",
"parentFolderId": "AAMk3AAA=",
"conversationId": "AAQkADEzOU4=",
"conversationIndex": "AdXReVPepTg==",
"isDeliveryReceiptRequested": null,
"isReadReceiptRequested": false,
"isRead": true,
"isDraft": false,
"webLink": "https://outlook.office365.com/owa/?ItemID=AAMkA%3D&exvsurl=1&viewmodel=ReadMessageItem",
"inferenceClassification": "focused",
"meetingMessageType": "meetingAccepted",
"body": {
"contentType": "text",
"content": ""
},
"sender": {
"emailAddress": {
"name": "Nicole",
"address": "sig#contoso.com"
}
},
"from": {
"emailAddress": {
"name": "Nicole",
"address": "sig#contoso.com"
}
},
"toRecipients": [
{
"emailAddress": {
"name": "Michael Mainer",
"address": "mm#contoso.com"
}
}
],
"ccRecipients": [],
"bccRecipients": [],
"replyTo": [],
"flag": {
"flagStatus": "notFlagged"
}
}

Create new mail message with Microsoft Graph API

When using the MS Graph API to POST a Mail message, the message is created in DRAFT mode. Is there any way to create a new regular mail message which is not in DRAFT?
In addition, is there any option to POST a new message using MIME format in the body?
When you create the Message you need to set the MessageFlags extended property to make it appear as if it was a Sent Message. You generally also want to set the ClientSubmitTime https://learn.microsoft.com/en-us/office/client-developer/outlook/mapi/pidtagclientsubmittime-canonical-property and the delivery time https://learn.microsoft.com/en-us/office/client-developer/outlook/mapi/pidtagmessagedeliverytime-canonical-property which affect how the messages will sort in Outlook. For MIME its export only in Beta at the moment https://developer.microsoft.com/en-us/graph/blogs/mime-format-support-for-microsoft-graph-apis-preview/
{
"Subject": "test1234",
"Sender": {
"EmailAddress": {
"Name": "blah",
"Address": "blah#blah.com"
}
},
"Body": {
"ContentType": "HTML",
"Content": "123Body"
},
"SingleValueExtendedProperties": [
{
"PropertyId": "Integer 0x0E07",
"Value": "1"
},
{
"PropertyId": "SystemTime 0x0039",
"Value": "2019-06-12T10:10:47.2048+10:00"
},
{
"PropertyId": "SystemTime 0x0E06",
"Value": "2019-06-12T10:10:47.2048+10:00"
}
]
}

Microsoft graph API: empty BCC field

Scenario:
Jenny and Tom have gmail accounts. Jerry is o365 user
Jenny sends email to Tom (in TO: field) and BCC: Jerry.
When Jerry gets message from graph api and doesn't see himself in BCC entry, which is empty (in both versions of API - 1 and beta).
If Jenny, Jerry and Tom would be in the group and Jenny have sent email to group, it would exactly the same for Jerry. There is no way to distinguish those two cases.
I would expect that when user is in BCC he should see himself there.
I know if sender is O365 user and getsMessage via graph API he will see all BCC users.
Is there any API call that I could use to learn that given user was in BCC of given message?
Here is what Jerry sees:
{
"#odata.etag": "W/\"CQAAABYAAACWhXAbJxpFRb0V3o8I2vIPAACwRstA\"",
"id": "AAMkAGMyNDE4NGI5LTRlNmItNDUzMy04ZTBlLTgxNjM3MDZhODE5NgBGAAAAAABT6x1NTxG_S7bw4uHJw-_tBwDEbTtXm_E6Rr8LT_x2xj5KAAAAnJfJAACWhXAbJxpFRb0V3o8I2vIPAACwGG_qAAA=",
"createdDateTime": "2017-11-15T19:50:57Z",
"lastModifiedDateTime": "2017-11-15T19:50:57Z",
"changeKey": "CQAAABYAAACWhXAbJxpFRb0V3o8I2vIPAACwRstA",
"categories": [],
"receivedDateTime": "2017-11-15T19:50:57Z",
"sentDateTime": "2017-11-15T19:50:54Z",
"hasAttachments": false,
"internetMessageId": "<CAHF5u5KsOQd43c4dtnx0uTQRor_dt7Y1uy=F3G4i6-c+TdUgug#mail.gmail.com>",
"subject": "test bcc=",
"bodyPreview": "test bcc",
"importance": "normal",
"parentFolderId": "AAMkAGMyE4NGI5LTRlNmItNDUzMy04ZTBlLTgxNjM3MDZhODE5NgAuAAAAAABT6x1NTxG_S7bw4uHJw-_tAQDEbTtXm_E6Rr8LT_x2xj5KAAAAnJfJAAA=",
"conversationId": "AAQkAGMyGI5LTRlNmItNDUzMy04ZTBlLTgxNjM3MDZhODE5NgAQAMaAYzrmsyxGq7ZujLh23q0=",
"conversationIndex": "AQHTXxoBjOuazLEartm6MuHberQ==",
"isDeliveryReceiptRequested": null,
"isReadReceiptRequested": false,
"isRead": false,
"isDraft": false,
"webLink": "https://outlook.office365.com/owa/?ItemID=AAMkAGMyNDE4NAACwGG%2BqAAA%3D&exvsurl=1&viewmodel=ReadMessageItem",
"inferenceClassification": "focused",
"unsubscribeData": [],
"unsubscribeEnabled": false,
"body": {
"contentType": "html",
"content": "<html>\r\n<head>\r\n<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n<meta content=\"text/html; charset=utf-8\">\r\n</head>\r\n<body>\r\n<div dir=\"ltr\">test bcc<br>\r\n</div>\r\n</body>\r\n</html>\r\n"
},
"sender": {
"emailAddress": {
"name": "Jenny",
"address": "jenny1234#gmail.com"
}
},
"from": {
"emailAddress": {
"name": "Jenny",
"address": "jenny1234#gmail.com"
}
},
"toRecipients": [
{
"emailAddress": {
"name": "Tom",
"address": "tom1234#gmail.com"
}
}
],
"ccRecipients": [],
"bccRecipients": [],
"replyTo": [],
"mentionsPreview": null,
"flag": {
"flagStatus": "notFlagged"
}
},
For any messages that comes from an external source (in this case GMail), there is no BCC data available.
This works this way in order to meet the requirements set forth for "Blind Carbon Copy" in RFC 2822.

Can't send emails to custom domains (non-gmail/hotmail emails) using Mailgun

I am sending out confirmation (and other emails) when users sign up. The problem is that when I send to addresses that are not gmail or hotmail or any of the larger email services, it throws me an error in the email header.
{
"severity": "permanent",
"tags": [],
"delivery-status": {
"tls": false,
"mx-host": "mxer.customdomain.com",
"code": 553,
"description": null,
"session-seconds": 6.566637992858887,
"message": "553 5.1.8 <user#customdomain.com>... Domain of sender address bounce+e06614.0f9698-user=customdomain.com#mg.mydomain.com does not exist",
"certificate-verified": false
},
"envelope": {
"transport": "smtp",
"sender": "accounts#mydomain.com",
"sending-ip": "123.45.678.900",
"targets": "user#customdomain.com"
},
"recipient-domain": "customdomain.com",
"id": "AbCDeFGhiJk_lMn",
"campaigns": [],
"reason": "generic",
"user-variables": {},
"flags": {
"is-routed": null,
"is-authenticated": true,
"is-system-test": false,
"is-test-mode": false
},
"log-level": "error",
"timestamp": 1456123374.411238,
"message": {
"headers": {
"to": "First Last <user#customdomain.com>",
"message-id": "56caade72ed26_***********9#6e5120c5-0d27-4491-a430-1a2dc4e6b862.mail",
"from": "Team Accounts <accounts#mydomain.com>",
"subject": "Confirmation instructions"
},
"attachments": [],
"recipients": [
"user#customdomain.com"
],
"size": 1143
},
"recipient": "user#customdomain.com",
"event": "failed"
}
Did I set my headers wrongly or is there a configuration I need to set up before I can send emails to custom domains?
It seems that for some email services, it requires a valid "receive" MX record for your domain/subdomain (for Mailgun it was mg.mydomain.com) to verify the identity of the sender. I added the MX records
10 mxa.mailgun.org
10 mxb.mailgun.org
for mg.mydomain.com and it seemed to have worked.

Resources