Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Outlook Folder tree

Reply
 
Old 11-20-2006   #1 (permalink)
Fil


 
 

Outlook Folder tree

Hi,

I am really new to Powershell (discovered it yesterday), and here is my
question :

This is working:

$a = New-Object -comObject Outlook.Application
$b = $a.getNamespace("MAPI").folders["whatever"]

where \\whatever is the folderpath of the whatever folder.
Now suppose \\whatever has a subfolder called subfolder1 whose folderpath is
\\whatever\subfolder1.

Why this doesn't work ??? :

$a = New-Object -comObject Outlook.Application
$b = $a.getNamespace("MAPI").folders["whatever"].folders["subfolder1"]

as I was used to do in vb with () instead of [] and collection instead of
this folders object I don't know what it is made of and how to deal with it.


Thank you for your answers

My System SpecsSystem Spec
Old 11-20-2006   #2 (permalink)
/\\/\\o\\/\\/ [MVP]


 
 

Re: Outlook Folder tree

Sometimes you can not use [] on a COM object (as it has no indexer)you also
can use the item() Method.

$b = $a.getNamespace("MAPI").folders.item("Public Folders")

PoSH>,$b | gm

$a.getNamespace("MAPI").folders["Public Folders"].folders.item("Favorites")

Greetings /\/\o\/\/

"Fil" <Fil@discussions.microsoft.com> wrote in message
news:87560101-F6DA-4C8F-9876-1CA22BC8D20E@microsoft.com...
> Hi,
>
> I am really new to Powershell (discovered it yesterday), and here is my
> question :
>
> This is working:
>
> $a = New-Object -comObject Outlook.Application
> $b = $a.getNamespace("MAPI").folders["whatever"]
>
> where \\whatever is the folderpath of the whatever folder.
> Now suppose \\whatever has a subfolder called subfolder1 whose folderpath
> is
> \\whatever\subfolder1.
>
> Why this doesn't work ??? :
>
> $a = New-Object -comObject Outlook.Application
> $b = $a.getNamespace("MAPI").folders["whatever"].folders["subfolder1"]
>
> as I was used to do in vb with () instead of [] and collection instead of
> this folders object I don't know what it is made of and how to deal with
> it.
>
>
> Thank you for your answers



My System SpecsSystem Spec
Old 11-20-2006   #3 (permalink)
Fil


 
 

Re: Outlook Folder tree

Thank you very much.
Is there a way to get a folder by specifying its folderpath instead of doing
something recursive ?

Cheers

"/\\/\\o\\/\\/ [MVP]" wrote:

> Sometimes you can not use [] on a COM object (as it has no indexer)you also
> can use the item() Method.
>
> $b = $a.getNamespace("MAPI").folders.item("Public Folders")
>
> PoSH>,$b | gm
>
> $a.getNamespace("MAPI").folders["Public Folders"].folders.item("Favorites")
>
> Greetings /\/\o\/\/
>
> "Fil" <Fil@discussions.microsoft.com> wrote in message
> news:87560101-F6DA-4C8F-9876-1CA22BC8D20E@microsoft.com...
> > Hi,
> >
> > I am really new to Powershell (discovered it yesterday), and here is my
> > question :
> >
> > This is working:
> >
> > $a = New-Object -comObject Outlook.Application
> > $b = $a.getNamespace("MAPI").folders["whatever"]
> >
> > where \\whatever is the folderpath of the whatever folder.
> > Now suppose \\whatever has a subfolder called subfolder1 whose folderpath
> > is
> > \\whatever\subfolder1.
> >
> > Why this doesn't work ??? :
> >
> > $a = New-Object -comObject Outlook.Application
> > $b = $a.getNamespace("MAPI").folders["whatever"].folders["subfolder1"]
> >
> > as I was used to do in vb with () instead of [] and collection instead of
> > this folders object I don't know what it is made of and how to deal with
> > it.
> >
> >
> > Thank you for your answers

>
>
>

My System SpecsSystem Spec
Old 11-20-2006   #4 (permalink)
Fil


 
 

Re: Outlook Folder tree

I am also looking for the same thing in vba (if ever it exists) by the way.

"Fil" wrote:

> Thank you very much.
> Is there a way to get a folder by specifying its folderpath instead of doing
> something recursive ?
>
> Cheers
>
> "/\\/\\o\\/\\/ [MVP]" wrote:
>
> > Sometimes you can not use [] on a COM object (as it has no indexer)you also
> > can use the item() Method.
> >
> > $b = $a.getNamespace("MAPI").folders.item("Public Folders")
> >
> > PoSH>,$b | gm
> >
> > $a.getNamespace("MAPI").folders["Public Folders"].folders.item("Favorites")
> >
> > Greetings /\/\o\/\/
> >
> > "Fil" <Fil@discussions.microsoft.com> wrote in message
> > news:87560101-F6DA-4C8F-9876-1CA22BC8D20E@microsoft.com...
> > > Hi,
> > >
> > > I am really new to Powershell (discovered it yesterday), and here is my
> > > question :
> > >
> > > This is working:
> > >
> > > $a = New-Object -comObject Outlook.Application
> > > $b = $a.getNamespace("MAPI").folders["whatever"]
> > >
> > > where \\whatever is the folderpath of the whatever folder.
> > > Now suppose \\whatever has a subfolder called subfolder1 whose folderpath
> > > is
> > > \\whatever\subfolder1.
> > >
> > > Why this doesn't work ??? :
> > >
> > > $a = New-Object -comObject Outlook.Application
> > > $b = $a.getNamespace("MAPI").folders["whatever"].folders["subfolder1"]
> > >
> > > as I was used to do in vb with () instead of [] and collection instead of
> > > this folders object I don't know what it is made of and how to deal with
> > > it.
> > >
> > >
> > > Thank you for your answers

> >
> >
> >

My System SpecsSystem Spec
Old 11-20-2006   #5 (permalink)
/\\/\\o\\/\\/ [MVP]


 
 

Re: Outlook Folder tree

nope,
but did you see this ?

$a = New-Object -comObject Outlook.Application
$f = $a.GetNamespace("MAPI").PickFolder()
$f

gr /\/\o\/\/
"Fil" <Fil@discussions.microsoft.com> wrote in message
news:AC3DCC70-3652-48BA-94F0-4F0E25435B7E@microsoft.com...
> Thank you very much.
> Is there a way to get a folder by specifying its folderpath instead of
> doing
> something recursive ?
>
> Cheers
>
> "/\\/\\o\\/\\/ [MVP]" wrote:
>
>> Sometimes you can not use [] on a COM object (as it has no indexer)you
>> also
>> can use the item() Method.
>>
>> $b = $a.getNamespace("MAPI").folders.item("Public Folders")
>>
>> PoSH>,$b | gm
>>
>> $a.getNamespace("MAPI").folders["Public
>> Folders"].folders.item("Favorites")
>>
>> Greetings /\/\o\/\/
>>
>> "Fil" <Fil@discussions.microsoft.com> wrote in message
>> news:87560101-F6DA-4C8F-9876-1CA22BC8D20E@microsoft.com...
>> > Hi,
>> >
>> > I am really new to Powershell (discovered it yesterday), and here is my
>> > question :
>> >
>> > This is working:
>> >
>> > $a = New-Object -comObject Outlook.Application
>> > $b = $a.getNamespace("MAPI").folders["whatever"]
>> >
>> > where \\whatever is the folderpath of the whatever folder.
>> > Now suppose \\whatever has a subfolder called subfolder1 whose
>> > folderpath
>> > is
>> > \\whatever\subfolder1.
>> >
>> > Why this doesn't work ??? :
>> >
>> > $a = New-Object -comObject Outlook.Application
>> > $b =
>> > $a.getNamespace("MAPI").folders["whatever"].folders["subfolder1"]
>> >
>> > as I was used to do in vb with () instead of [] and collection instead
>> > of
>> > this folders object I don't know what it is made of and how to deal
>> > with
>> > it.
>> >
>> >
>> > Thank you for your answers

>>
>>
>>



My System SpecsSystem Spec
Old 11-20-2006   #6 (permalink)
Marty List


 
 

Re: Outlook Folder tree


If it's a user created folder, I don't know how to find it except for looping.
If it's one of the default folders, try the GetDefaultFolder() method:
http://msdn2.microsoft.com/en-gb/library/ms526181.aspx


According to MSDN, these should be the correct values, but they're not working
for me (with Outlook 2007):

$CdoDefaultFolderCalendar = 0
$CdoDefaultFolderContacts = 5
$CdoDefaultFolderDeletedItems = 4
$CdoDefaultFolderInbox = 1
$CdoDefaultFolderJournal = 6
$CdoDefaultFolderNotes = 7
$CdoDefaultFolderOutbox = 2
$CdoDefaultFolderSentItems = 3
$CdoDefaultFolderTasks = 8

$Outlook = New-Object -comObject "Outlook.Application"
$DeletedItems = $Outlook.Session.GetDefaultFolder($CdoDefaultFolderDeletedItems)
$DeletedItems.FolderPath

There might be an easier way to do it with a reference to CDO, something similar
to this:
$DeletedItems =
$Outlook.Session.GetDefaultFolder([CdoDefaultFolderTypes]::CDO.CdoDefaultFolderDeletedItems)



"Fil" <Fil@discussions.microsoft.com> wrote in message
news:51BBB054-5445-416E-8C98-1B8E9B168FBA@microsoft.com...
>I am also looking for the same thing in vba (if ever it exists) by the way.
>
> "Fil" wrote:
>
>> Thank you very much.
>> Is there a way to get a folder by specifying its folderpath instead of doing
>> something recursive ?
>>
>> Cheers
>>
>> "/\\/\\o\\/\\/ [MVP]" wrote:
>>
>> > Sometimes you can not use [] on a COM object (as it has no indexer)you also
>> > can use the item() Method.
>> >
>> > $b = $a.getNamespace("MAPI").folders.item("Public Folders")
>> >
>> > PoSH>,$b | gm
>> >
>> > $a.getNamespace("MAPI").folders["Public Folders"].folders.item("Favorites")
>> >
>> > Greetings /\/\o\/\/
>> >
>> > "Fil" <Fil@discussions.microsoft.com> wrote in message
>> > news:87560101-F6DA-4C8F-9876-1CA22BC8D20E@microsoft.com...
>> > > Hi,
>> > >
>> > > I am really new to Powershell (discovered it yesterday), and here is my
>> > > question :
>> > >
>> > > This is working:
>> > >
>> > > $a = New-Object -comObject Outlook.Application
>> > > $b = $a.getNamespace("MAPI").folders["whatever"]
>> > >
>> > > where \\whatever is the folderpath of the whatever folder.
>> > > Now suppose \\whatever has a subfolder called subfolder1 whose folderpath
>> > > is
>> > > \\whatever\subfolder1.
>> > >
>> > > Why this doesn't work ??? :
>> > >
>> > > $a = New-Object -comObject Outlook.Application
>> > > $b =
>> > > $a.getNamespace("MAPI").folders["whatever"].folders["subfolder1"]
>> > >
>> > > as I was used to do in vb with () instead of [] and collection instead of
>> > > this folders object I don't know what it is made of and how to deal with
>> > > it.
>> > >
>> > >
>> > > Thank you for your answers
>> >
>> >
>> >



My System SpecsSystem Spec
Old 11-21-2006   #7 (permalink)
Fil


 
 

Re: Outlook Folder tree

Thank you.

That would have been nice :

$a = New-Object -comObject Outlook.Application
$b =
$a.getNamespace("MAPI").getFolder("\\rootFolder1\subfolderr\...\subfolderN")



"/\\/\\o\\/\\/ [MVP]" wrote:

> nope,
> but did you see this ?
>
> $a = New-Object -comObject Outlook.Application
> $f = $a.GetNamespace("MAPI").PickFolder()
> $f
>
> gr /\/\o\/\/
> "Fil" <Fil@discussions.microsoft.com> wrote in message
> news:AC3DCC70-3652-48BA-94F0-4F0E25435B7E@microsoft.com...
> > Thank you very much.
> > Is there a way to get a folder by specifying its folderpath instead of
> > doing
> > something recursive ?
> >
> > Cheers
> >
> > "/\\/\\o\\/\\/ [MVP]" wrote:
> >
> >> Sometimes you can not use [] on a COM object (as it has no indexer)you
> >> also
> >> can use the item() Method.
> >>
> >> $b = $a.getNamespace("MAPI").folders.item("Public Folders")
> >>
> >> PoSH>,$b | gm
> >>
> >> $a.getNamespace("MAPI").folders["Public
> >> Folders"].folders.item("Favorites")
> >>
> >> Greetings /\/\o\/\/
> >>
> >> "Fil" <Fil@discussions.microsoft.com> wrote in message
> >> news:87560101-F6DA-4C8F-9876-1CA22BC8D20E@microsoft.com...
> >> > Hi,
> >> >
> >> > I am really new to Powershell (discovered it yesterday), and here is my
> >> > question :
> >> >
> >> > This is working:
> >> >
> >> > $a = New-Object -comObject Outlook.Application
> >> > $b = $a.getNamespace("MAPI").folders["whatever"]
> >> >
> >> > where \\whatever is the folderpath of the whatever folder.
> >> > Now suppose \\whatever has a subfolder called subfolder1 whose
> >> > folderpath
> >> > is
> >> > \\whatever\subfolder1.
> >> >
> >> > Why this doesn't work ??? :
> >> >
> >> > $a = New-Object -comObject Outlook.Application
> >> > $b =
> >> > $a.getNamespace("MAPI").folders["whatever"].folders["subfolder1"]
> >> >
> >> > as I was used to do in vb with () instead of [] and collection instead
> >> > of
> >> > this folders object I don't know what it is made of and how to deal
> >> > with
> >> > it.
> >> >
> >> >
> >> > Thank you for your answers
> >>
> >>
> >>

>
>
>

My System SpecsSystem Spec
Old 11-21-2006   #8 (permalink)
Fil


 
 

Re: Outlook Folder tree

Instead I see we have

$a = New-Object -comObject Outlook.Application
$b = $a.getNamespace("MAPI").getFolderFromID()



"Fil" wrote:

> Thank you.
>
> That would have been nice :
>
> $a = New-Object -comObject Outlook.Application
> $b =
> $a.getNamespace("MAPI").getFolder("\\rootFolder1\subfolderr\...\subfolderN")
>
>
>
> "/\\/\\o\\/\\/ [MVP]" wrote:
>
> > nope,
> > but did you see this ?
> >
> > $a = New-Object -comObject Outlook.Application
> > $f = $a.GetNamespace("MAPI").PickFolder()
> > $f
> >
> > gr /\/\o\/\/
> > "Fil" <Fil@discussions.microsoft.com> wrote in message
> > news:AC3DCC70-3652-48BA-94F0-4F0E25435B7E@microsoft.com...
> > > Thank you very much.
> > > Is there a way to get a folder by specifying its folderpath instead of
> > > doing
> > > something recursive ?
> > >
> > > Cheers
> > >
> > > "/\\/\\o\\/\\/ [MVP]" wrote:
> > >
> > >> Sometimes you can not use [] on a COM object (as it has no indexer)you
> > >> also
> > >> can use the item() Method.
> > >>
> > >> $b = $a.getNamespace("MAPI").folders.item("Public Folders")
> > >>
> > >> PoSH>,$b | gm
> > >>
> > >> $a.getNamespace("MAPI").folders["Public
> > >> Folders"].folders.item("Favorites")
> > >>
> > >> Greetings /\/\o\/\/
> > >>
> > >> "Fil" <Fil@discussions.microsoft.com> wrote in message
> > >> news:87560101-F6DA-4C8F-9876-1CA22BC8D20E@microsoft.com...
> > >> > Hi,
> > >> >
> > >> > I am really new to Powershell (discovered it yesterday), and here is my
> > >> > question :
> > >> >
> > >> > This is working:
> > >> >
> > >> > $a = New-Object -comObject Outlook.Application
> > >> > $b = $a.getNamespace("MAPI").folders["whatever"]
> > >> >
> > >> > where \\whatever is the folderpath of the whatever folder.
> > >> > Now suppose \\whatever has a subfolder called subfolder1 whose
> > >> > folderpath
> > >> > is
> > >> > \\whatever\subfolder1.
> > >> >
> > >> > Why this doesn't work ??? :
> > >> >
> > >> > $a = New-Object -comObject Outlook.Application
> > >> > $b =
> > >> > $a.getNamespace("MAPI").folders["whatever"].folders["subfolder1"]
> > >> >
> > >> > as I was used to do in vb with () instead of [] and collection instead
> > >> > of
> > >> > this folders object I don't know what it is made of and how to deal
> > >> > with
> > >> > it.
> > >> >
> > >> >
> > >> > Thank you for your answers
> > >>
> > >>
> > >>

> >
> >
> >

My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Windows Explorer: folder shortcut, can't navigate up the folder tree Vista General
XP-style folder tree in explorer Vista file management
Folder tree in Windows Vista Vista General
Report changes in folder tree PowerShell
Whhither the folder tree? Vista General


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46