# Author: Robbie Allen (2003.12.07) # # This script sets the view for all folders in the default Inbox and # personal folders you specify. I wrote this to work around the problem in # Outlook 2003 where you cannot set a view to be applied across all folders # in a tree. I got tired of setting the views for each folder manually. my $DEBUG = 0; # 1 = debugging enabled, just display folder tree; 0 = set views my $DO_INBOX = 0; # 1 = set inbox folders; 0 = don't set inbox folders my @personal_folders = ("Personal Folders","Work Folders"); # @personal_folders = ("RSS Feeds"); use Win32::OLE 'in'; my $objApp = Win32::OLE->GetActiveObject("Outlook.Application"); my $objOutlook = $objApp->GetNamespace("MAPI"); my $objFolders; if ($DO_INBOX) { $objFolders = $objOutlook->GetDefaultFolder(6)->Folders; # 6 = Inbox print "Default Inbox:\n"; foreach my $objFolder ( in $objFolders) { subfolders($objFolder," "); } print "\n"; } foreach my $pst (@personal_folders) { print "$pst:\n"; $objFolders = $objOutlook->Folders($pst)->Folders; foreach my $objFolder ( in $objFolders) { subfolders($objFolder," "); } print "\n"; } sub subfolders { my ($objFs,$spaces) = @_; print $spaces,$objFs->Name; if ($DEBUG) { print "\n"; } else { my $rc = setview($objFs); if ($rc) { print " (ERROR setting view)\n"; } else { print " (set view)\n"; } } my $objSubFs = $objFs->Folders; return unless ref $objSubFs; foreach my $objF (in $objSubFs) { subfolders($objF,"$spaces "); } } sub setview { my ($objFolder) = @_; my $objViews = $objFolder->Views; my $objView = $objViews->Item("Messages"); return -1 unless ref $objView; # print $objView->{XML} && exit; $objView->{XML} = qq( Messages table-layout:fixed;width:100%;font-family:Tahoma;font-style:normal;font-weight:normal;font-size:8pt;color:Black;font-charset:0 0 8421504 3 0 background-color:#FFFFFF background-color:#D3D3D3 color:Blue 0 1 boolicon Attachment urn:schemas:httpmail:hasattachment boolean 1 10 3 Importance urn:schemas:httpmail:importance i4 1 10 From urn:schemas:httpmail:fromname string 40 1 Subject urn:schemas:httpmail:subject string 181 Received urn:schemas:httpmail:datereceived datetime 806551552 54 M/d/yyyy||h:mm tt 2 Received urn:schemas:httpmail:datereceived datetime desc 0 2 1 0 ); $objView->Save; $objView->Apply; } __END__ Flag Status http://schemas.microsoft.com/mapi/proptag/0x10900003 i4 1 18