Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / November 2006

Tip: Looking for answers? Try searching our database.

Creating Mailbox Top Level Folder with VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Boy from Oz - 23 Nov 2006 23:49 GMT
I am trying to work out how to create a folder in Outlook that is on the same
level as the Inbox. The code I am working with is:

   Dim onMAPI As NameSpace
   Dim ofInboxFolder As MAPIFolder
   Dim ofNewFolder As MAPIFolder
   
   Set onMAPI = Application.GetNamespace("MAPI")
   Set ofInboxFolder = onMAPI.GetDefaultFolder(olFolderInbox)
   
   On Error Resume Next
   If ofInboxFolder.Folders("New Folder") Is Nothing Then
       ofInboxFolder.Folders.Add "New Folder", olFolderInbox
   End If
   
   Set ofInboxFolder = Nothing
   Set ofNewFolder = Nothing
   Set onMAPI = Nothing

How to I make this: Set ofInboxFolder = onMAPI.GetDefaultFolder(olFolderInbox)
be the "Mailbox - Username" Folder?

On the same point, how do I then reference this new folder to capture when a
new message is dropped/created in it?

Thanks in advance.
Sue Mosher [MVP-Outlook] - 24 Nov 2006 02:12 GMT
The Inbox has a Parent, and Folders.Add returns the new folder:

   Set newFolder = ofInboxFolder.Parent.Folders.Add("New Folder", olFolderInbox)

Signature

Sue Mosher, Outlook MVP
  Author of Configuring Microsoft Outlook 2003
    http://www.turtleflock.com/olconfig/index.htm
  and Microsoft Outlook Programming - Jumpstart for
    Administrators, Power Users, and Developers
    http://www.outlookcode.com/jumpstart.aspx
 

>I am trying to work out how to create a folder in Outlook that is on the same
> level as the Inbox. The code I am working with is:
[quoted text clipped - 22 lines]
>
> Thanks in advance.
Boy from Oz - 24 Nov 2006 07:05 GMT
Thanks, that worked a treat...

> The Inbox has a Parent, and Folders.Add returns the new folder:
>
>     Set newFolder = ofInboxFolder.Parent.Folders.Add("New Folder", olFolderInbox)
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.