Trying to send an email through Microsoft Graph where another email from user mailbox is to be used as an attachment.
What I am doing is something similar to:
POST https://graph.microsoft.com/v1.0/me/sendMail HTTP/1.1
authorization: bearer {access_token}
content-type: application/json
content-length: 96
{
"message": {
"subject": "Meet for lunch?",
"body": {
"contentType": "Text",
"content": "The new cafeteria is open."
},
"toRecipients": [{
"emailAddress": {
"address": "garthf#a830edad9050849NDA1.onmicrosoft.com"
}
}],
"attachments": [
"#odata.type": "#Microsoft.OutlookServices.ItemAttachment",
"name": "menu.txt",
"item": {
"id": "some_id"
<!--This is the id of an existing email in User's inbox -->
}
]
},
"saveToSentItems": "false"
}
This returns with
Cannot process input of abstract type Microsoft.OutlookServices.Item
Can anyone help with suggestions?
Related
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
I am learning to use Swagger to document my API, and everything was well-explained until I got to the authentication portion. To give you some context of my API's authentication: it uses passport-jwt to authenticate users, sends an access token in the response body, and sets a refresh token in an httpOnly cookie. This is the swagger.json documentation I have so far:
{
"swagger": "2.0",
"info": {
"title": "API",
"description": "Coin-based API",
"version": "1.0.0"
},
"host": "localhost:4000",
"schemes": ["http"],
"consumes": ["application/json"],
"produces": ["application/json"],
"components": {
"securitySchemes": {
"bearerAuth": {
"type": "http",
"scheme": "bearer",
"in": "header",
"bearerFormat": "JWT"
}
}
},
"paths": {
"/api/users/transfer": {
"patch": {
"summary": "Transfer coins from one user to another",
"description": "Transfers coins from one user to another",
"security": [
{
"bearerAuth": []
}
],
"parameters": [
{
"name": "body",
"in": "body",
"schema": {
"type": "object",
"properties": {
"amount": {
"example": "any"
},
"recipient": {
"example": "any"
}
}
}
}
],
"responses": {
"200": {
"description": "Returns the user's new balance"
},
"400": {
"description": "Cannot transfer to yourself and/or Amount must be greater than 0"
},
"401": {
"description": "Unauthorized"
},
"403": {
"description": "Insufficient funds"
},
"404": {
"description": "User not found"
}
}
}
},
I couldn't find a good reference on what the best practices are to let the client know that he needs to send a access token in the header. Right now on my swagger Ui, I see a an open lock and no information about the authorization process. What should I do?
I expect the client to see the information about the authorization process and able to send a request with an access token.
When I send batch request made of calendar appointment request to Graph API, I seldom encounter a improper response from the API: some XML are injected as is in the JSON response.
This is impossible to unserialize, so I cannot know which appointment had issues, and it leaves no choice but to reiterate the same calendar appointments batch, which poses performance issue.
The request to batch API looks as follow (I intentionally hide information with *** in the post data below and did not show with ... the 3 others requests to calendar Graph API)
POST https://graph.microsoft.com/v1.0/$batch
Accept: application/json
Content-Type: application/json
{
"requests": [
{
"id": "33",
"method": "PATCH",
"url": "/me/calendars/***/events/***",
"body": {
"subject": "***",
"location": {
"displayname": "***"
},
"body": {
"content": "***"
},
"categories": ["***"],
"start": {
"dateTime": "2021-05-12 06:00:00",
"timeZone": "UTC"
},
"end": {
"dateTime": "2021-05-12 07:00:00",
"timeZone": "UTC"
},
"showAs": "free",
"isReminderOn": false,
"reminderMinutesBeforeStart": 0,
"singleValueExtendedProperties": [{
"id": "String {***} Name ***",
"value": "***"
}
]
},
"headers": {
"Content-Type": "application/json"
}
}, {
"id": "34",
...
}
]
}
This is what I seldom get (before and later on, the same id worked just fine)
{
"responses": [
{
"id": "33",
"status": 503,
"headers": {
"Content-Type": "text/html; charset=us-ascii"
},
"body":<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">
<HTML><HEAD><TITLE>Service Unavailable</TITLE>
<META HTTP-EQUIV="Content-Type" Content="text/html; charset=us-ascii"></HEAD>
<BODY><h2>Service Unavailable</h2>
<hr><p>HTTP Error 503. The service is unavailable.</p>
</BODY></HTML>
}, {
"id": "34",
"status": 200
...
}
]
}
Could you please investigate this issue and render a proper JSON response in any case, even if it fails with a 503 response?
Note: I reported this bug at https://github.com/microsoftgraph/microsoft-graph-docs/issues/12951 but none of the solution provided by the automated closing message was relevant.
I rather reported the bug to the right github repo https://github.com/microsoftgraph/msgraph-sdk-serviceissues/issues/93
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"
}
}
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"
}
]
}