Current way to report a message
In these days, the v1.0 and beta versions of the Microsoft Graph API allow you to mark a message as junk with the markAsJunk
action.
Mark message as junk
Mark a message as junk. This API adds the sender to the list of blocked senders and moves the message to the Junk Email folder, when the moveToJunk
property is true.
POST v1.0/me/messages/{message_id}/markAsJunk
POST beta/me/messages/{message_id}/markAsJunk
{
"MoveToJunk": true
}
Mark message as not junk
Similar to the markAsJunk
action, you can also mark a message as not junk with the markAsNotJunk
action. The sender is removed from the list of blocked users.
POST v1.0/me/messages/{message_id}/markAsNotJunk
POST beta/me/messages/{message_id}/markAsNotJunk
{
"moveToInbox": true
}
If the moveToInbox
property is set to true, the message will be moved back to the Inbox folder.
Be aware that the message is not moved to original folder but to the Inbox folder. If the message was moved to Junk from custom folder, it will be moved to the Inbox folder.
If you check your Outlook client, you will probably see that there is also the option to report the mail as phishing.
New API to report a message
The beta version of the Microsoft Graph introduces a new API to report messages as junk, phishing, or not junk. This new API provides more options and flexibility for reporting messages.
Report message as junk
POST /beta/me/messages/{message_id}/reportMessage
{
"isMessageMoveRequested": "true",
"reportAction": "junk"
}
If you set isMessageMoveRequested
to true
, the message will be moved to the Junk Email folder. The reportAction
can be set to junk
, phishing
, or notJunk
.
Be aware that message id is changed when a message is moved to another folder.
The response type is the microsoft.graph.reportMessageCommandResult
resource even if the documentation claims that the response type should be message
.
Report message as not junk
POST /beta/me/messages/{message_id}/reportMessage
{
"isMessageMoveRequested": "true",
"reportAction": "notJunk"
}
If you set isMessageMoveRequested
to true
, the message will be moved back to the Inbox folder.
Unfortunately, if the message was moved to Junk from custom folder, it will be moved to the Inbox folder.
Report message as phishing
POST /beta/me/messages/{message_id}/reportMessage
{
"isMessageMoveRequested": "true",
"reportAction": "phish"
}
If you set isMessageMoveRequested
to true
, the message will be moved to the Deleted Items folder.
Want to revert the change? Just call the same API with reportAction
set to notJunk
.