How to receive email messages in plain text format in Graph Explore

Asuka Hoda 26 Reputation points
2022-11-10T13:55:41.467+00:00

Is it possible in Graph Explorer to convert to text format when get messages?

It is explained that if you set "Prefer: outlook.body-content-type=text" in the request header, you can get it in text format, but it is in a state where you can only get it in HTML format.

https://learn.microsoft.com/en-us/graph/api/message-get?view=graph-rest-1.0&tabs=http#request-headers

My goal is to use Java's SDK to get email messages in plain text, but I'm afraid the HTTP functionality isn't working.

This is a note set in the request header.
【Key】:【Value】            【Results】
Prefer:outlook.body-content-type:text → Bad Request - 400
prefer:outlook.body-content-type:text → Bad Request - 400
Prefer:text              → Response preview:"contentType": "html"、Java:requestOptions.add(new HeaderOption("Prefer", "text"));
prefer:text              → Response preview:"contentType": "html"、Java:requestOptions.add(new HeaderOption("prefer", "text"));
outlook.body-content-type:text     → Response preview:"contentType": "html"、Java:requestOptions.add(new HeaderOption("outlook.body-content-type", "text"));

Is it a problem only for Graph Explorer that it can not be obtained in text format?

Microsoft Security | Microsoft Graph
{count} votes

Accepted answer
  1. Srinivasa Rao Darna 6,761 Reputation points Microsoft External Staff
    2022-11-10T14:49:45.433+00:00

    Hello @Asuka Hoda ,

    Thanks for reach Microsoft Q&A!
    I am able to successfully get message body in text format with example Get message body in text format.

    GET https://graph.microsoft.com/v1.0/me/messages/{message-id}  
    Prefer: outlook.body-content-type="text"  
    

    Key: Prefer
    Value: outlook.body-content-type="text"

    259107-image.png

    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    1 person found this answer helpful.
    0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  4. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.