How to create mail folder/ sub folder using IMAP?

Hello All,

I am trying to find a way to create a mail folder/ subfolder using IMAP. With UiPath mail activities, we can either move or read emails. There’s no option to create a mail folder.

I have managed to create a mail folder using outlook features. i.e. Microsoft.Office.Interop.Outlook. However, due to the size of the mailbox, it’s slow. Also, at times, outlook stops responding. Hence I want to create a mail folder using IMAP.

Is there any way to create a mail folder using IMAP? Scripts are also fine like python, vb, or PowerShell scripts.

@Srini84 @Learning_Technologies @Latika10011740 tagging you guys as you have experience in IMAP. Hoping to get some resolution at the earliest.

Happy Automating :fire:

@kiran.suryavanshi

Have a look below threads.

Hey @lakshman,

Thanks for the prompt response :slight_smile:

The solution or threads you provided are dependent on the outlook application which is something I would like to avoid as outlook hangs at least once a day due to mailbox size. Hence using the outlook application to create custom folders is not an ideal solution for me. Also, the folder created through the outlook application doesn’t sync quickly which causes issues while IMAP activity is looking for the newly created folder.

Is there any other programmatic way to create a mail folder without using the outlook application?

Thanks :vulcan_salute:

Hi All,

Found a solution to create mail folders using IMAP programmatically with help of python. It’s quite easy. Posting the solution below so it would help the community.

import imaplib

M = imaplib.IMAP4_SSL("imap.example.org","port number in integer")
M.login("username", "password")
M.create("New Folder Name")
M.logout

Please note, you can create nested folder in one go as well. All you have to do is separate folder name by forward slash / e.g. Inbox/SubFolder1/SubFolder2

Happy Automating :slight_smile: :fire:

3 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.