question

NamitPandey-9983 avatar image
0 Votes"
NamitPandey-9983 asked NamitPandey-9983 commented

Adding Category to Mail using graph api

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@outlook.com"
}
}
],
"categories": [
"Project expenses"
]
}
}

microsoft-graph-mail
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RajeshKumarMSFT-6137 avatar image
0 Votes"
RajeshKumarMSFT-6137 answered NamitPandey-9983 commented

Hi @NamitPandey-9983,

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



draftemail.png (17.1 KiB)
send.png (44.3 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @RajeshKumarMSFT-6137,

Thanks for your reply. I did all the mentioned steps, the mail is drafted with the category attached but while using the send API the mail is sent with all the mentioned parameters except the category. For some reason the category is getting removed if we send the mail. Let me know if I missed any steps.

205823-image.png

205797-image.png

205769-image.png

205770-image.png


0 Votes 0 ·
image.png (172.3 KiB)
image.png (16.8 KiB)
image.png (71.6 KiB)
image.png (47.2 KiB)