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

How To Refer To Custom Folder in VBA



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old May 8th 10, 06:33 PM posted to microsoft.public.outlook.program_vba
Rich Locus
external usenet poster
 
Posts: 8
Default 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
Ads
  #2  
Old May 8th 10, 06:49 PM posted to microsoft.public.outlook.program_vba
Rich Locus
external usenet poster
 
Posts: 8
Default 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

 




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
How do I refer to user field in VB Bev Kaufman Outlook and VBA 1 April 23rd 10 10:22 AM
How to refer to a given Outlook Message from another MicrosoftApplication Paul Schrum Outlook and VBA 1 January 18th 08 06:41 AM
Moving a Custom Form from folder to folder in Outlook 2007 koops2121 Outlook - Using Forms 8 September 24th 07 11:14 PM
Refer original Item from new form sriramna Outlook - Using Forms 9 March 26th 07 03:56 PM
refer to "To" Field in Code Joel Outlook and VBA 10 December 7th 06 02:35 AM


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


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