question

HarryJaggard-2503 avatar image
0 Votes"
HarryJaggard-2503 asked AtulThorat-MSFT edited

Forwarding email

Hi everyone,

I want to forward all email from my company's email that contains some specific keywords to another webmail. How can I fill the trigger part and do it?

Thank you so much!


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

AtulThorat-MSFT avatar image
0 Votes"
AtulThorat-MSFT answered AtulThorat-MSFT edited

Hi @HarryJaggard-2503 ,

Hope you are doing well.

We can create Message Rule using below graph api endpoint.

Please refer mailfolder-post-messagerules microsoft article for the same.

Outlook carries out those actions if an incoming message in the user's Inbox meets the specified conditions.

 Permissions
    
 Delegated (work or school account)     MailboxSettings.ReadWrite
 Delegated (personal Microsoft account) MailboxSettings.ReadWrite
 Application                            MailboxSettings.ReadWrite

 Graph API Endpoint
    
 POST https://graph.microsoft.com/v1.0/me/mailFolders/inbox/messageRules
    
 Request Header
    
 Content-type: application/json
    
 Request Body
    
 {
     "displayName": "Keyword Rule",
     "sequence": 1,
     "isEnabled": true,
     "conditions": {
         "bodyContains": [
             "test"
         ]
     },
     "actions": {
         "forwardTo": [
             {
                 "emailAddress": {
                     "name": "User Name",
                     "address": "user@o365xx.onmicrosoft.com"
                 }
             }
         ],
         "stopProcessingRules": true
     }
 }
    
 Graph API Response
    
 {
     "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users('6ab5cc33-a9d6-40b1-a84f-993e06d170f3')/mailFolders('inbox')/messageRules/$entity",
     "id": "AQAAAEegLYU=",
     "displayName": "Keyword Rule",
     "sequence": 1,
     "isEnabled": true,
     "hasError": false,
     "isReadOnly": false,
     "conditions": {
         "bodyContains": [
             "test"
         ]
     },
     "actions": {
         "stopProcessingRules": true,
         "forwardTo": [
             {
                 "emailAddress": {
                     "name": "User Name",
                     "address": "user@o365xx.onmicrosoft.com"
                 }
             }
         ]
     }
 }

197360-rule-creation.png

So in this way you can forward email that contains specific keyword to another user with webmail

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


rule-creation.png (67.0 KiB)
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.