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

Creating Mailbox Top Level Folder with VBA



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old November 23rd 06, 11:49 PM posted to microsoft.public.outlook.program_vba
Boy from Oz
external usenet poster
 
Posts: 1
Default Creating Mailbox Top Level Folder with VBA

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.
Ads
  #2  
Old November 24th 06, 02:12 AM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Creating Mailbox Top Level Folder with VBA

The Inbox has a Parent, and Folders.Add returns the new folder:

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

--
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

"Boy from Oz" Boy from wrote in message ...
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.

  #3  
Old November 24th 06, 07:05 AM posted to microsoft.public.outlook.program_vba
Boy from Oz
external usenet poster
 
Posts: 1
Default Creating Mailbox Top Level Folder with VBA

Thanks, that worked a treat...

"Sue Mosher [MVP-Outlook]" wrote:

The Inbox has a Parent, and Folders.Add returns the new folder:

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

--
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


 




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
Correct way to get top-level folder of newly added store (new PST file) [email protected] Outlook and VBA 2 September 22nd 06 11:47 PM
Permission error when creating rule in your own mailbox? MC Outlook - Installation 6 June 28th 06 03:02 PM
Best Practices for creating Resource Mailbox Accounts scooter79 Outlook - Calandaring 4 June 22nd 06 08:47 PM
create meeting request from another mailbox in VBA? Nick B Outlook and VBA 1 March 7th 06 07:09 PM
Creating a PST file at the server level Amwendwa Outlook - General Queries 8 February 10th 06 01:01 PM


All times are GMT +1. The time now is 03:36 PM.


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.