问题
I am currently using Microsoft Graph API to retrieve my email, send new email and answer to an email.
I use Code Grant authorization to identify my user and access its information.
PROBLEM
This application let the user send email to our customers that have unpaid invoice. But the application uses GET https://graph.microsoft.com/v1.0/me/messages
(with $search
set to the customer email) to retrieve every mail that involves the customer, so the user can trace every conversation made by other employees.
The problem is to be able to differentiate emails (sent from our app) from others mails (sent from Outlook app). We would like to use email headers, which are accepted by a large amount of mail servers, and with which we could filter the search result to inform the user which email comes from our app.
The desired outcome would be that for example, I could be able to call Microsoft Graph API like so :
GET https://graph.microsoft.com/v1.0/me/messages
with OData Parameters :$search="john.doe@gmail.com"
and$select=subject,bodyPreviewreceivedDateTime,headers
- Then asuming the request has send back a
200
code the JSON output would be :
Notice the X-MY-COMPANY-INVOICE
, which would be the ultimate goal for us to let the app be aware this was sent from our app and not from Outlook app.
QUESTION
Is there any way to perform this using Microsoft Graph API? If not, does Microsoft plan to release this feature any soon?
QUESTION 2
I am opened to suggestion, is this the best way to do this or am I going right on the wall with this technique? If yes, what would be the best way to overcome this issue?
回答1:
This is a good use case for Extensions. You can use these mechanisms to attach custom data to an element (messages, events, users, groups, etc.).
There are several types of extensions available with Microsoft Graph: Extended Properties, Open Extensions or Schema Extension. Each has it's own set of constraints so it is worth reviewing each to determine which works best for your scenario and architecture. That said, based on your description, I suspect Schema Extensions may be the best fit here.
来源:https://stackoverflow.com/questions/47711529/add-custom-headers-and-retrieive-custom-header-using-microsoft-graph-api