Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HOWTO Create a folder programatically in Outlook

Status
Not open for further replies.

blakey2

MIS
Jan 28, 2004
313
AU
Hi All,

After scratching around a bit managed to hack this together & thought it might be useful.

Essentailly needed to create a VB script that would create a new Folder under the 'Mailbox' of the user.

I referenced these two sites so full credit to the authors:

Please note that this is pretty clumsy, it uses 'On Error Resume Next' to avoid generting errors when folder already exists etc.


Cheers.

Code:
' ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
' :::  Add Outlook Folder "DesiredFolderName" & set homepage.
' :::
' :::  Written: 01 Feb 2010
' :::
' :::  Arguments: None
' :::
' :::  This script will create a folder in the 'Mailbox Root' of the
' :::  user's mailbox. This folder is called Archive Manager.
' :::  The script will set the HomePage of this folder to:
' :::                    [URL unfurl="true"]http://desiredhomepage.com.au[/URL]
' :::
' ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::


Set objOutlook = CreateObject("Outlook.Application")
Set myNameSpace = objOutlook.GetNamespace("MAPI")
Set myInboxFolder = myNameSpace.GetDefaultFolder(6)
' Get 'mailbox root'
Set myFolder = myInboxFolder.parent

'Suppress Error message (eg. If folder already exists)
On Error Resume Next

' Create Folder
Set myNewFolder = myFolder.Folders.Add("DesiredFolderName") 

' Set Folder Homepage
myNewFolder.WebViewAllowNavigation = True
myNewFolder.WebViewURL = "[URL unfurl="true"]http://desiredhomepage.com.au"[/URL]
myNewFolder.WebViewOn = True
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top