Adding Category to Mail using graph api

asked 2022-05-25T10:20:06.51+00:00
Namit Pandey 1 Reputation point

Hi,

I'm trying to add category to a mail during send/forward/reply (using graph api) but unable to do so. Mail are being sent but without any category attached. Can anyone help me to solve what am I doing wrong (see code snippet below). Thanks in advance

{
"message": {
"subject": "Meet for lunch?",
"body": {
"contentType": "Text",
"content": "The new cafeteria is open."
},
"toRecipients": [
{
"emailAddress": {
"address": "abc@harsh.com .com"
}
}
],
"categories": [
"Project expenses"
]
}
}

Microsoft Graph Mail API
Microsoft Graph Mail API
A Microsoft API that supports accessing data in users' primary mailboxes and in shared mailboxes.
679 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. answered 2022-05-25T18:41:44.893+00:00
    RajeshKumarMSFT 1,936 Reputation points Microsoft Employee

    Hi @Namit Pandey ,

    Hope you are doing well,

    To set categories for message, you need to draft a message using this graph API endpoint. Refer

    Post:-https://graph.microsoft.com/v1.0/me/messages
    205488-draftemail.png

    Once the message draft action is completed (above step) ,you can see this message in in your sent items with category selected. after this you have to send email by capturing the message ID from previous step.

    To Send message Using this graph API endpoint https://graph.microsoft.com/v1.0/me/messages/{msgid}/send -Refer
    205565-send.png

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