When working with Outlook, managing a growing number of emails becomes difficult very quickly. Important messages like invoices, resumes, or client updates often get lost in a crowded inbox, making it hard to stay organized and respond on time.

Most users try to handle this with manual folders or static rules, but these solutions don’t scale well as email patterns keep changing. This leads to extra effort, missed emails, and reduced productivity.

Goal

  • Create folder based on subject and save mail in folder.

Screenshot - 2026-06-02T172529.415

Step-wise Implementation

1 - Create flow

  • Go to make.powerautomate.com

  • Choose trigger like when email arrives (from Office 365 Outlook)

Screenshot - 2026-06-02T172741.779

2 - Initialize variable for subject

  • Here, i am split subject with character (-).

Code
trim(split(triggerOutputs()?['body/subject'], '-')[0])
Screenshot - 2026-06-02T172808.703

3 - Check folder exist

  • Add HTTP action Office 365 Outlook

Code
https://graph.microsoft.com/v1.0/me/mailFolders?$filter=displayName eq '@{variables('varSubject')}'
Screenshot - 2026-06-02T172930.497

4 - Filter records of Check folder exist

  • Add Filter array action.

  • From:

    Code
    body('Send_an_HTTP_request_-_Check_folder_exist')?['value']
  • condition:

Code
@equals(item()?['displayName'], variables('varSubject'))
Screenshot - 2026-06-02T173252.311

5 - Add Condition

  • Check that if there is already folder in Outlook

  • Condition:

Code
length(body('Filter_array')) is not equal to 0
Screenshot - 2026-06-02T173321.936

6 - Yes section (Move mail to already created folder)

Uri:

Code
https://graph.microsoft.com/v1.0/me/messages/@{triggerOutputs()?['body/id']}/move

Body:

Code
{
  'destinationId': '@{first(body('Send_an_HTTP_request_-_Check_folder_exist')?['value'])?['id']}'
}
Screenshot - 2026-06-02T173603.108

7 - No section (Create folder then move mail to that folder)

1 - Create folder

Uri:

Code
https://graph.microsoft.com/v1.0/me/mailFolders

Body:

Code
{
'displayName': '@{variables('varSubject')}',
'parentFolderId': 'AQMkADgzODA4YjI3LWY1ZDktNDYxZS1hMmJhLTg5NTc3ADk2MGQxYTQALgAAA8F7eCT-O3RBuqORFOIoQxMBABdTtfS6Z39GkKhT-7qE4UAAAAIBCAAAAA=='
}
  • Here i have hardcoded value of Parent Folder ID, you can get by requesting - Get method with same above Url.

Screenshot - 2026-06-02T174032.652

2 - Move mail to newly created folder

Uri:

Code
https://graph.microsoft.com/v1.0/me/messages/@{triggerOutputs()?['body/id']}/move

Body:

Code
{
  'destinationId': '@{body('Send_an_HTTP_request_-_Create_folder_2')?['id']}'
}
Screenshot - 2026-06-02T174433.934

Conclusion

Here, we learnt that how we can automate this hectic process of Mail using Power Automate.