Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   How To Refer To Custom Folder in VBA (http://www.outlookbanter.com/outlook-vba/102459-how-refer-custom-folder-vba.html)

Rich Locus May 8th 10 06:33 PM

How To Refer To Custom Folder in VBA
 
Hello Outlook Group:

I am trying to reference a CUSTOM user folder at the same level as all the
other folders:

For example, I have a folder called MyEmails that appears in the Outlook
tree as follows:

Calendar
Contacts
Deleted Items
Drafts
Inbox
MyEmails

The VBA code I'm using from Access works for the Inbox, but fails on the
MAPI setup of the MyEmails Folder:

Set Inbox = OlApp.GetNamespace("Mapi").GetDefaultFolder(olFold erInbox)
Set MyEmailFolder = OlApp.GetNamespace("Mapi").Folders("MyEmail")

I don't want to the the GetDefaultFolder because it isn't one. Does anyone
know the code to create the Namespace for "MyEmail"?

Thanks,
Rich Locus


--
Rich Locus
Logicwurks, LLC

Rich Locus May 8th 10 06:49 PM

How To Refer To Custom Folder in VBA
 
I finally came up with the code to do this... I had to refer to the Parent
directory of the Inbox:

Set MyEmailFolder =
OlApp.GetNamespace("Mapi").GetDefaultFolder(olFold erInbox).Parent.Folders("MyEmail")
--
Rich Locus
Logicwurks, LLC


"Rich Locus" wrote:

Hello Outlook Group:

I am trying to reference a CUSTOM user folder at the same level as all the
other folders:

For example, I have a folder called MyEmails that appears in the Outlook
tree as follows:

Calendar
Contacts
Deleted Items
Drafts
Inbox
MyEmails

The VBA code I'm using from Access works for the Inbox, but fails on the
MAPI setup of the MyEmails Folder:

Set Inbox = OlApp.GetNamespace("Mapi").GetDefaultFolder(olFold erInbox)
Set MyEmailFolder = OlApp.GetNamespace("Mapi").Folders("MyEmail")

I don't want to the the GetDefaultFolder because it isn't one. Does anyone
know the code to create the Namespace for "MyEmail"?

Thanks,
Rich Locus


--
Rich Locus
Logicwurks, LLC



All times are GMT +1. The time now is 05:43 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com