Adding Category to Mail using graph api

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

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
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,476 questions
0 comments No comments
{count} votes

1 answer

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

    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".