freebsdboy has asked for the wisdom of the Perl Monks concerning the following question:

I'm in the process of a mail system migration project, from MS Exchange to Linux based Scalix. The Scalix migration toolkit doesn't have a clean way to migrate the few important aspects of Public Folders. Namely A Public folder owners, ACL list and the folder hierarchy. I've pulled some code from this site to list through the names of the folders from this site, and modified it a little to read the public folders. This works great. The issue I'm having now is that I'm not a windows programmer and don't know what methods or actions to use to get the data I need for each public folder. I've started looking at the UserProperties item but don't know how to list all the properties of an item. Here is the code as it stands now
#!/bin/perl use Win32::OLE; use Win32::OLE::Const 'Microsoft Outlook'; # or 'Microsoft Outlook 9.0 Object Library'; # Const module defines many usefule constants - like olFolderContacts +, etc. my $Outlook = Win32::OLE->GetActiveObject('Outlook.Application') or di +e "oops 1"; my $namespace = $Outlook->GetNamespace("MAPI"); my $folder = $namespace->GetDefaultFolder(olPublicFoldersAllPublicFold +ers); my $items = $folder->Items; print STDERR "Folder: ", $folder->Name,"\n"; print STDERR "Total entries: ",$items->Count,"\n"; print_folders($folder); sub print_folders { my $folder = shift; my $subfolderlevel=0; print "Folder: " . $folder->Name , $subfolderlevel,"\n"; foreach my $fld (in $folder->(UserProperties)) { print "Field Name", $fld->{Name},"\n"; print "Field Value", $fld->Value, "\n"; } if ($folder->Folders->Count) { $subfolderlevel++; foreach my $i (1..$folder->Folders->Count) { print_folders($folder->Folders($i)); } } }
I see that you can get the message subject by using item->Subject etc.. but its not clear what use when I'm looking for a Public Folders Owner ACL list and sub folder hierarchy Thanks

Replies are listed 'Best First'.
Re: Pulling UserProperties out of Outlook
by tachyon-II (Chaplain) on Dec 01, 2007 at 06:07 UTC

    You basically have 3 options when working with OLE.

    • You can learn to love MSDN and RTFM about methods and properties.
    • You can Google for some C++ or VB code that does something like what you want and convert that to Perl (my preferred lazy approach)
    • You can explore the object you have by digging ever deeper. Data::Dumper sometimes works but will often struggle (ie crash/never finish) at the top levels so sometimes you need to hand enumerate a level or two (like you are doing), then take a SWAG and enumerate deeper levels that look interesting. The _NewEnum option of Win32::OLE is also of value

    http://www.outlookcode.com/ is one of the sites that has sample outlook code in other languages. This may work for you:

    use Data::Dumper; ..... print Data::Dumper::Dumper($folder->(UserProperties));
      It turns out that the Outlook Public folder values I need are not available via the object model(OLE). They are available only via CDO. I think CDO can be used in limited capacity on the systems I'm using, but CDO looks like more work than I'm interested in doing. I found a tool that will get me the data I need. Its called pfinfo.exe Its download-able from ftp://ftp.microsoft.com/PSS/Tools/Exchange%20Support%20Tools/PFInfo/55/ thanks for the guidance.