A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Script the creation of NEW public folders in EX2K3



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old October 20th 06, 10:43 AM posted to microsoft.public.outlook.program_vba,microsoft.public.exchange.development
Road Rebel
external usenet poster
 
Posts: 3
Default Script the creation of NEW public folders in EX2K3

I'm looking to add many new public folders to an already existing heirarcy of
public folders in exchange 2003. Is there any code that can be run against
the root folder and create new folders within all the subfolders?

example

Root
-----Subfolder1(Already Exists)
+--------------2006(Exists Already)
---------------2007(Needs to be created)
----------------------------------------------Cars(needs to be created)
----------------------------------------------Housing(needs to be created)
----------------------------------------------Air(needs to be created)
----------------------------------------------GT(needs to be created)
-----Subfolder2(Already Exists)
+--------------2006(Exists Already)
---------------2007(Needs to be created)
----------------------------------------------Cars(needs to be created)
----------------------------------------------Housing(needs to be created)
----------------------------------------------Air(needs to be created)
----------------------------------------------GT(needs to be created)


I have to do this a minimum 300 times every year and it keeps getting
bigger...

I have about 90 days before this needs to happen and any help would be
greatly appreciated.

-Jeff

Ads
  #2  
Old October 20th 06, 06:51 PM posted to microsoft.public.outlook.program_vba,microsoft.public.exchange.development
Eric Legault [MVP - Outlook]
external usenet poster
 
Posts: 830
Default Script the creation of NEW public folders in EX2K3

Try the macros below; run CreateFolderSetInSubFolders and choose the folder
that corresponds to the Root you illustrated in your example.

Sub CreateFolderSetInSubFolders()
On Error Resume Next

Dim objRootFolder As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder

Set objNS = Application.GetNamespace("MAPI")
'top level folder
Set objRootFolder = objNS.PickFolder

If objRootFolder Is Nothing Then Exit Sub

'create folder sets in subfolders of chosen folder
For Each objFolder In objRootFolder.Folders
CreateFolderSet objFolder
Next

Set objRootFolder = Nothing
Set objFolder = Nothing
Set objNS = Nothing
End Sub

Private Sub CreateFolderSet(objCurrentFolder As Outlook.MAPIFolder)
On Error Resume Next

Dim objFolder As Outlook.MAPIFolder

Set objFolder = objCurrentFolder.Folders("2007")

If objFolder Is Nothing Then
'folder doesn't exist - create
Set objFolder = objCurrentFolder.Folders.Add("2007")
objFolder.Folders.Add "Cars"
objFolder.Folders.Add "Housing"
objFolder.Folders.Add "Air"
objFolder.Folders.Add "GT"
End If

Set objFolder = Nothing
End Sub

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Road Rebel" wrote:

I'm looking to add many new public folders to an already existing heirarcy of
public folders in exchange 2003. Is there any code that can be run against
the root folder and create new folders within all the subfolders?

example

Root
-----Subfolder1(Already Exists)
+--------------2006(Exists Already)
---------------2007(Needs to be created)
----------------------------------------------Cars(needs to be created)
----------------------------------------------Housing(needs to be created)
----------------------------------------------Air(needs to be created)
----------------------------------------------GT(needs to be created)
-----Subfolder2(Already Exists)
+--------------2006(Exists Already)
---------------2007(Needs to be created)
----------------------------------------------Cars(needs to be created)
----------------------------------------------Housing(needs to be created)
----------------------------------------------Air(needs to be created)
----------------------------------------------GT(needs to be created)


I have to do this a minimum 300 times every year and it keeps getting
bigger...

I have about 90 days before this needs to happen and any help would be
greatly appreciated.

-Jeff

  #3  
Old October 20th 06, 07:09 PM posted to microsoft.public.outlook.program_vba,microsoft.public.exchange.development
Road Rebel
external usenet poster
 
Posts: 3
Default Script the creation of NEW public folders in EX2K3

Phenominal!!! Thank you very much!!!

"Eric Legault [MVP - Outlook]" wrote:

Try the macros below; run CreateFolderSetInSubFolders and choose the folder
that corresponds to the Root you illustrated in your example.

Sub CreateFolderSetInSubFolders()
On Error Resume Next

Dim objRootFolder As Outlook.MAPIFolder
Dim objNS As Outlook.NameSpace
Dim objFolder As Outlook.MAPIFolder

Set objNS = Application.GetNamespace("MAPI")
'top level folder
Set objRootFolder = objNS.PickFolder

If objRootFolder Is Nothing Then Exit Sub

'create folder sets in subfolders of chosen folder
For Each objFolder In objRootFolder.Folders
CreateFolderSet objFolder
Next

Set objRootFolder = Nothing
Set objFolder = Nothing
Set objNS = Nothing
End Sub

Private Sub CreateFolderSet(objCurrentFolder As Outlook.MAPIFolder)
On Error Resume Next

Dim objFolder As Outlook.MAPIFolder

Set objFolder = objCurrentFolder.Folders("2007")

If objFolder Is Nothing Then
'folder doesn't exist - create
Set objFolder = objCurrentFolder.Folders.Add("2007")
objFolder.Folders.Add "Cars"
objFolder.Folders.Add "Housing"
objFolder.Folders.Add "Air"
objFolder.Folders.Add "GT"
End If

Set objFolder = Nothing
End Sub

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Road Rebel" wrote:

I'm looking to add many new public folders to an already existing heirarcy of
public folders in exchange 2003. Is there any code that can be run against
the root folder and create new folders within all the subfolders?

example

Root
-----Subfolder1(Already Exists)
+--------------2006(Exists Already)
---------------2007(Needs to be created)
----------------------------------------------Cars(needs to be created)
----------------------------------------------Housing(needs to be created)
----------------------------------------------Air(needs to be created)
----------------------------------------------GT(needs to be created)
-----Subfolder2(Already Exists)
+--------------2006(Exists Already)
---------------2007(Needs to be created)
----------------------------------------------Cars(needs to be created)
----------------------------------------------Housing(needs to be created)
----------------------------------------------Air(needs to be created)
----------------------------------------------GT(needs to be created)


I have to do this a minimum 300 times every year and it keeps getting
bigger...

I have about 90 days before this needs to happen and any help would be
greatly appreciated.

-Jeff

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
OL2k3 Automatically Adding Public Folders to 'Favorite Folders' list in Mail Ben Outlook - General Queries 0 October 4th 06 05:19 PM
OE will not allow creation of a new folder under local folders ElaineMF Outlook Express 11 September 6th 06 10:02 PM
Automate Public Folder Creation John Mc Cabe Outlook and VBA 1 August 16th 06 05:01 PM
Is there a way to display Public Folders in the All Mail Folders view? Outlook2003 Cappy Outlook - Installation 1 July 20th 06 03:20 AM
Change default view for creation of new personal folders Bob Outlook - Installation 1 April 19th 06 04:56 AM


All times are GMT +1. The time now is 08:20 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.