Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Outlook and VBA (http://www.outlookbanter.com/outlook-vba/)
-   -   Create a new store - where is it? (http://www.outlookbanter.com/outlook-vba/28132-create-new-store-where.html)

Anyone for Coffee? September 26th 06 09:27 PM

Create a new store - where is it?
 

Using C#

I have a valid NameSpaceClass.

I use AddStore (path) to add a store. How can I then go and find the store?

I can look in the NameSpaceClass.Folders Collection and search for it, but
how do I KNOW I've found the right store? By default when I add a store it
seems to take the name "Personal Folder", but what if there is already a
"Personal Folder"?

It seems the AddStore method should return the Stoe that was created (or
found).

Thanks,





Sue Mosher [MVP-Outlook] September 26th 06 09:42 PM

Create a new store - where is it?
 
Before you create the store, iterate all open stores and get their StoreIDs.

Then after you create the store, use Namespace.Folders.GetLast to get the last store. Compare its StoreID with those that you collected earlier. If it matches none of them, then you know it's the store you added. If it does match, repeat Folders.GetPrevious until you find one with no match. At that point, you can change its display name to make it easier to locate in future sessions.

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

"Anyone for Coffee?" wrote in message ...

Using C#

I have a valid NameSpaceClass.

I use AddStore (path) to add a store. How can I then go and find the store?

I can look in the NameSpaceClass.Folders Collection and search for it, but
how do I KNOW I've found the right store? By default when I add a store it
seems to take the name "Personal Folder", but what if there is already a
"Personal Folder"?

It seems the AddStore method should return the Stoe that was created (or
found).

Thanks,





Anyone for Coffee? September 26th 06 10:43 PM

Create a new store - where is it?
 
Thanks Sue,

Your suggestion is what I had decided to, but it doesn't feel right.

Is there a more 'thread-safe' way of doing this? If two instances were to
add a store at the same time I wouldn't know which added which. I don't think
that will happen, but in theory it could.



Sue Mosher [MVP-Outlook] September 28th 06 03:22 PM

Create a new store - where is it?
 
I don't know of any other way to do it. The scenario you describe would be so rare as to be not worth spending a lot of time on, IMO.

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

"Anyone for Coffee?" wrote in message ...
Thanks Sue,

Your suggestion is what I had decided to, but it doesn't feel right.

Is there a more 'thread-safe' way of doing this? If two instances were to
add a store at the same time I wouldn't know which added which. I don't think
that will happen, but in theory it could.




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

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