How to create a folder under another PST file or mailbox (not just the defaultStore)

Hi
Just wondering if this is similar way to create folder under another PST rather than just the defaultstore?

//------------------
“Variable” oapp = new Microsoft.Office.Interop.Outlook.ApplicationClass

“Assign activity” oFolders = oapp.Session.GetFolderPath(“myPSTname\inbox”).Folders
//error: option strict on disallow later binding

“Assign activity” NewFolder = oFolders(“Inbox”).Folders.Add(“newFolderName”, Type.Missing)
//------------------

also here is a reference for create a folder under outlook defaultStore

thanks

Hi webon99,

Have you managed to deal with this problem?

My idea is to use Microsoft HowTo code to support automation.
https://docs.microsoft.com/en-us/office/vba/outlook/how-to/items-folders-and-stores/obtain-a-folder-object-from-a-folder-path

This is VB so it should be possible to convert it into a UIpath activity.

Hi I managed to deal with it. Thanks to various pieces of information from UI Path forum and aformentioned code!
mBoxFolderCreator.xaml (16.1 KB)

3 Likes

Hi, have you had to use this with shared mailbox subfolders by any chance? It works perfectly for top level outlook folders but I need to be able to look at subfolders :frowning:

Hello,
you can assign below codes to create NewFolderA\NewFolderB on given Inbox folder.

This one creates only NewFolderB, NewFolderA exists:
oFolders(Inbox).folders(NewFolderA).Folders.Add(NewFolderB,Type.Missing)

This creates whole tree of folders:
oFolders(Inbox).Folders.Add(NewFolderA,Type.Missing).Folders.Add(NewFolderB,Type.Missing)

Keep in mind that Inbox name will be different in other language versions of outlook.
There is also Outlook folder limitation of 500. After that it might cause issues like not finding folder that was created second ago.

Rav

1 Like

Thanks, this works.