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

Correct way to get top-level folder of newly added store (new PST file)



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 23rd 06, 12:03 AM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 3
Default Correct way to get top-level folder of newly added store (new PST file)

I need to know how to get the top-level folder for the store that I
just opened/created with AddStore. My code looks like this right now:

.... (create olApp object) ...
CNameSpace olNs(olApp.GetNamespace("MAPI"));
olNs.AddStore(COleVariant(CString("C:\\plhtest.pst ")));
CFolders folders = olNs.get_Folders();
CMAPIFolder folder = folders.GetLast();
.... (do stuff with folder) ...
olNs.RemoveStore(folder);

Is that the correct way to get the folder? I read somewhere that you
aren't guaranteed that the last folder is the right one for the store
you just added, but if not, what is the right way? The AddStore
function doesn't have a return value!

Thanks,
Phillip Hellewell

Ads
  #2  
Old September 23rd 06, 12:17 AM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default Correct way to get top-level folder of newly added store (new PST file)

You shouldn't assume that the latest added will the "last." Instead, maintain an array of the StoreID values for all the current stores, then use GetLast and see if its StoreID is in the array. If it isn't, then you have the right store. If it is in the array, try again with GetPrevious.

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

wrote in message oups.com...
I need to know how to get the top-level folder for the store that I
just opened/created with AddStore. My code looks like this right now:

... (create olApp object) ...
CNameSpace olNs(olApp.GetNamespace("MAPI"));
olNs.AddStore(COleVariant(CString("C:\\plhtest.pst ")));
CFolders folders = olNs.get_Folders();
CMAPIFolder folder = folders.GetLast();
... (do stuff with folder) ...
olNs.RemoveStore(folder);

Is that the correct way to get the folder? I read somewhere that you
aren't guaranteed that the last folder is the right one for the store
you just added, but if not, what is the right way? The AddStore
function doesn't have a return value!

Thanks,
Phillip Hellewell

  #3  
Old September 23rd 06, 12:47 AM posted to microsoft.public.outlook.program_vba
[email protected]
external usenet poster
 
Posts: 3
Default Correct way to get top-level folder of newly added store (new PST file)

Sue Mosher [MVP-Outlook] wrote:
You shouldn't assume that the latest added will the "last." Instead, maintain an array of the StoreID values for all the current stores, then use GetLast and see if its StoreID is in the array. If it isn't, then you have the right store. If it is in the array, try again with GetPrevious.


Thank you. While this isn't as straightforward as I had hoped for, it
is doable.

Phillip

 




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
Having trouble getting my newly added email account to work Cary, NC Outlook - Installation 5 September 6th 06 10:40 PM
1000 Messages deleted from sent folder (PST File) Benabd Outlook - General Queries 5 September 2nd 06 02:42 AM
Scheduling-tab needs a "Month" zoom level added. J3 Outlook - Calandaring 0 July 14th 06 06:38 AM
Creating a PST file at the server level Amwendwa Outlook - General Queries 8 February 10th 06 02:01 PM
getting error: this .pst file is not a valid personal folder file jen98 Outlook - Installation 1 February 2nd 06 12:37 AM


All times are GMT +1. The time now is 09:52 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.