PC Review


Reply
Thread Tools Rate Thread

Creating a folders collection

 
 
Water Cooler v2
Guest
Posts: n/a
 
      22nd Sep 2005
It is possible to create folders (MAPIFolder) within the Personal
Folders collection. I learnt that it is also possible to create a top
level folder in the heirarchy, of the same level as Outlook Personal
Folders, with a piece of code like this:


Application.GetNamespace("MAPI").AddStore("MyPSTFile.pst")


However, there are two problems with this approach:

(1) The new folder always gets the name "Personal Folders" irrespective
of the new PST file you create. Can you have a personalized name for
this new store? How?

(2) The method AddStore is a sub-procedure and not a function. In
effect, it doesn't return a value, which one might expect, might be a
reference to the newly added folder collection. How do you get a
reference to the newly added store or folders collection?

(3) Unless you have a reference, you cannot change the name of the
newly created store. Even if we did have a reference, I see that you
cannot change the name of the collection (out of the code, i.e. not
programmatically) even in design mode if you clicked on the
context-menu, "Properties for Personal Folders".

 
Reply With Quote
 
 
 
 
=?Utf-8?B?RXJpYyBMZWdhdWx0IFtNVlAgLSBPdXRsb29rXQ==
Guest
Posts: n/a
 
      22nd Sep 2005
The semantics of whether AddStore is a procedure or function (where did you
see it described that way?) is really irrelevant, and indeed the VBA help
file calls both "Methods".

Anyway, if you use AddStore to create a new .pst, it is now a new Folder in
the top NameSpace.Folders collection. So if you added a second .pst file,
you can set a reference to a MAPIFolder object by setting it to
NameSpace.Folders(2):

Dim myFolder As Outlook.MAPIFolder
Set myFolder = Application.GetNameSpace("MAPI").Folders(2)

This now gives you access to the top level of the store, and all of its
subfolder by walking through the Folders collection.

You actually CAN change the display name of any store, just by setting a
MAPIFolder object to the root of the store like above, then changing the
MAPIFolder.Name property. But then you have to do this:

Application.GetNamespace("MAPI").RemoveStore myFolder
Application.GetNamespace("MAPI").AddStore "C:\Test\test.pst"

This will refresh the display name. Otherwise, the name will refresh once
you restart Outlook.

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard - http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Water Cooler v2" wrote:

> It is possible to create folders (MAPIFolder) within the Personal
> Folders collection. I learnt that it is also possible to create a top
> level folder in the heirarchy, of the same level as Outlook Personal
> Folders, with a piece of code like this:
>
>
> Application.GetNamespace("MAPI").AddStore("MyPSTFile.pst")
>
>
> However, there are two problems with this approach:
>
> (1) The new folder always gets the name "Personal Folders" irrespective
> of the new PST file you create. Can you have a personalized name for
> this new store? How?
>
> (2) The method AddStore is a sub-procedure and not a function. In
> effect, it doesn't return a value, which one might expect, might be a
> reference to the newly added folder collection. How do you get a
> reference to the newly added store or folders collection?
>
> (3) Unless you have a reference, you cannot change the name of the
> newly created store. Even if we did have a reference, I see that you
> cannot change the name of the collection (out of the code, i.e. not
> programmatically) even in design mode if you clicked on the
> context-menu, "Properties for Personal Folders".
>
>

 
Reply With Quote
 
Water Cooler v2
Guest
Posts: n/a
 
      23rd Sep 2005
Thanks for the help, Eric. I have one more problem now.


After I make my folder, I am trying to let it get selected and then on
its selection, open up a web-page like so:


fld.WebViewAllowNavigation = True
fld.WebViewURL = "http://foobar.com"
fld.WebViewOn = True

However, when this happens, I do not see any webpage come up. When I
right-click on the folder to view its properties, too, I do not see
either the home page set nor the check box, "Show home page by default
for this folder" set to on.

How do I do this?


Thanks.



Eric Legault [MVP - Outlook] wrote:
> The semantics of whether AddStore is a procedure or function (where did you
> see it described that way?) is really irrelevant, and indeed the VBA help
> file calls both "Methods".
>
> Anyway, if you use AddStore to create a new .pst, it is now a new Folder in
> the top NameSpace.Folders collection. So if you added a second .pst file,
> you can set a reference to a MAPIFolder object by setting it to
> NameSpace.Folders(2):
>
> Dim myFolder As Outlook.MAPIFolder
> Set myFolder = Application.GetNameSpace("MAPI").Folders(2)
>
> This now gives you access to the top level of the store, and all of its
> subfolder by walking through the Folders collection.
>
> You actually CAN change the display name of any store, just by setting a
> MAPIFolder object to the root of the store like above, then changing the
> MAPIFolder.Name property. But then you have to do this:
>
> Application.GetNamespace("MAPI").RemoveStore myFolder
> Application.GetNamespace("MAPI").AddStore "C:\Test\test.pst"
>
> This will refresh the display name. Otherwise, the name will refresh once
> you restart Outlook.
>
> --
> Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
> Try Picture Attachments Wizard - http://www.collaborativeinnovations.ca
> Blog: http://blogs.officezealot.com/legault/
>
>
> "Water Cooler v2" wrote:
>
> > It is possible to create folders (MAPIFolder) within the Personal
> > Folders collection. I learnt that it is also possible to create a top
> > level folder in the heirarchy, of the same level as Outlook Personal
> > Folders, with a piece of code like this:
> >
> >
> > Application.GetNamespace("MAPI").AddStore("MyPSTFile.pst")
> >
> >
> > However, there are two problems with this approach:
> >
> > (1) The new folder always gets the name "Personal Folders" irrespective
> > of the new PST file you create. Can you have a personalized name for
> > this new store? How?
> >
> > (2) The method AddStore is a sub-procedure and not a function. In
> > effect, it doesn't return a value, which one might expect, might be a
> > reference to the newly added folder collection. How do you get a
> > reference to the newly added store or folders collection?
> >
> > (3) Unless you have a reference, you cannot change the name of the
> > newly created store. Even if we did have a reference, I see that you
> > cannot change the name of the collection (out of the code, i.e. not
> > programmatically) even in design mode if you clicked on the
> > context-menu, "Properties for Personal Folders".
> >
> >


 
Reply With Quote
 
=?Utf-8?B?RXJpYyBMZWdhdWx0IFtNVlAgLSBPdXRsb29rXQ==
Guest
Posts: n/a
 
      23rd Sep 2005
Try running tihs right after:

ActiveExplorer.SelectFolder ActiveExplorer.CurrentFolder

--
Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"Water Cooler v2" wrote:

> Thanks for the help, Eric. I have one more problem now.
>
>
> After I make my folder, I am trying to let it get selected and then on
> its selection, open up a web-page like so:
>
>
> fld.WebViewAllowNavigation = True
> fld.WebViewURL = "http://foobar.com"
> fld.WebViewOn = True
>
> However, when this happens, I do not see any webpage come up. When I
> right-click on the folder to view its properties, too, I do not see
> either the home page set nor the check box, "Show home page by default
> for this folder" set to on.
>
> How do I do this?
>
>
> Thanks.
>
>
>
> Eric Legault [MVP - Outlook] wrote:
> > The semantics of whether AddStore is a procedure or function (where did you
> > see it described that way?) is really irrelevant, and indeed the VBA help
> > file calls both "Methods".
> >
> > Anyway, if you use AddStore to create a new .pst, it is now a new Folder in
> > the top NameSpace.Folders collection. So if you added a second .pst file,
> > you can set a reference to a MAPIFolder object by setting it to
> > NameSpace.Folders(2):
> >
> > Dim myFolder As Outlook.MAPIFolder
> > Set myFolder = Application.GetNameSpace("MAPI").Folders(2)
> >
> > This now gives you access to the top level of the store, and all of its
> > subfolder by walking through the Folders collection.
> >
> > You actually CAN change the display name of any store, just by setting a
> > MAPIFolder object to the root of the store like above, then changing the
> > MAPIFolder.Name property. But then you have to do this:
> >
> > Application.GetNamespace("MAPI").RemoveStore myFolder
> > Application.GetNamespace("MAPI").AddStore "C:\Test\test.pst"
> >
> > This will refresh the display name. Otherwise, the name will refresh once
> > you restart Outlook.
> >
> > --
> > Eric Legault (Outlook MVP, MCDBA, old school WOSA MCSD, B.A.)
> > Try Picture Attachments Wizard - http://www.collaborativeinnovations.ca
> > Blog: http://blogs.officezealot.com/legault/
> >
> >
> > "Water Cooler v2" wrote:
> >
> > > It is possible to create folders (MAPIFolder) within the Personal
> > > Folders collection. I learnt that it is also possible to create a top
> > > level folder in the heirarchy, of the same level as Outlook Personal
> > > Folders, with a piece of code like this:
> > >
> > >
> > > Application.GetNamespace("MAPI").AddStore("MyPSTFile.pst")
> > >
> > >
> > > However, there are two problems with this approach:
> > >
> > > (1) The new folder always gets the name "Personal Folders" irrespective
> > > of the new PST file you create. Can you have a personalized name for
> > > this new store? How?
> > >
> > > (2) The method AddStore is a sub-procedure and not a function. In
> > > effect, it doesn't return a value, which one might expect, might be a
> > > reference to the newly added folder collection. How do you get a
> > > reference to the newly added store or folders collection?
> > >
> > > (3) Unless you have a reference, you cannot change the name of the
> > > newly created store. Even if we did have a reference, I see that you
> > > cannot change the name of the collection (out of the code, i.e. not
> > > programmatically) even in design mode if you clicked on the
> > > context-menu, "Properties for Personal Folders".
> > >
> > >

>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft ASP .NET 1 18th May 2007 10:24 AM
Collection problems (create Collection object, add data to collection, bind collection to datagrid) Øyvind Isaksen Microsoft Dot NET 1 18th May 2007 10:24 AM
Creating a folders collection or store Water Cooler v2 Microsoft Outlook 0 22nd Sep 2005 07:08 PM
Creating a new collection from an existing collection marcus.wade@smart-rs.com Microsoft VB .NET 5 8th Aug 2005 05:47 PM
Creating a new collection from an existing collection marcus.wade@smart-rs.com Microsoft VB .NET 2 3rd Aug 2005 12:43 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:48 PM.