Outlook and VBA: create folders in pst file

Archangelos

New Member
Joined
Aug 21, 2017
Messages
49
Hello guys,

firstly I wish to all of you a happy and prosperous 2019.

Well, I have to create a new pst for the personal emails of 2019. It's not difficult.

However, I have to make a number of folder with a specific tree structure.

Any idea?

I have a little VBA experience with excel but I am totally clueless with Outlook.
 

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).
For example:
Code:
Sub Add2019Folder()
Dim myNameSpace As Outlook.NameSpace
Dim myBFolder As Folder
Dim myNew2019 As Folder
 
   Set myNameSpace = Application.GetNamespace("MAPI")
   Set myBFolder = myNameSpace.GetDefaultFolder(olFolderInbox)    'Base folder
   Set myNew2019 = myBFolder.Folders.Add("Y_2019")
   myNew2019.Folders.Add ("SubFold_1")
   myNew2019.Folders("SubFold_1").Folders.Add ("SubFold_1a")
   myNew2019.Folders.Add ("SubFold_2")
   myNew2019.Folders("SubFold_2").Folders.Add ("SubFold_2a")
End Sub
This will create, within the Inbox folder, the following new forders structure
Code:
InBox
   Y_2019
      SubFold_1
         SubFold_1a
      SubFold_2
         SubFold_2a

Adapt the code to create your own structure

Bye
 
Upvote 0
Thanks buddy,

my apologies for my late response but I saw it a couple of minutes ago.

I have a question, the code creates a new pst file?
 
Upvote 0

Forum statistics

Threads
1,213,531
Messages
6,114,172
Members
448,554
Latest member
Gleisner2

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top