![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| | #4 (permalink) |
| | 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 Specs![]() |
| | #5 (permalink) |
| | 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 Specs![]() |
| | #6 (permalink) |
| | 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 Specs![]() |
| | #7 (permalink) |
| | 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 Specs![]() |
| | #8 (permalink) |
| | 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 Specs![]() |
![]() |
| 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 | |||