I used something like this in a project I started a couple of years ago.
I'll post the script so you can see what it looks like, but it has been a
long time since I have even looked at this script. I know it works, and it
does get the folders on some levels, and you can see that. Some of the loops
and prints are in there just because I was learning when I wrote this, and
needed to see what was being returned.
 
This was the beginning of a little project to consolidate the data on when
people were scheduled to be out of the office. It has some stuff I was doing
to learn to navigate through the folders, and it navigates to a calendar
object on our network, pulls relevant data, and puts it into Excel. I'd take
out everything but the stuff you were asking for if I had a little time to
spend on it, but as it is, I think you can see what I am doing, and get the
information you need from it.
 
Let me know if you have further questions after you get a chance to look at
this, and I'll see what I can do to help.
 
Hope this helps,
 
Steve H.
 
 

use Win32;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Outlook';
use Win32::OLE::NLS qw( :DATE :LOCALE );
use BitWise qw(RGB);                            # this is my module. You
probably need to remove all references to RGB
                                                            # or to BitWise.

*Error = *Win32::OLE::LastError;          # Create a shortcut because I'm a
lazy typist.

# open an outlook object:
my $otl = Win32::OLE->new('Outlook.Application');
# create a session:
my $sess = $otl->Session();

# print the total number of Folders to search:
print "Folders on this level: " . $sess->Folders->Count();
my $totalFolders = $sess->Folders->Count();

foreach (1 .. $totalFolders)
{
   # print each key and value for each folder on this level:
   print "$_ is " . $sess->Folders(1)->{$_}. "\n" foreach sort keys
%{$sess->Folders(1)};
   print "\n\n\n\n";
}

# all work below this point is work I was actually doing to pull items from
a spreadsheet
# and put them in an Excel spreadsheet.

my $cal = $sess->Folders('Public Folders')->Folders('All Public
Folders')->Folders('National Practices');
$cal =
$cal->Folders('Americas')->Folders('US')->Folders('Clusters')->Folders('Mid
America')->Folders('Calendars');
$cal = $cal->Folders('US TULSA DTO IT DEPT');
#outkeys ($cal);

print "\nItems:\n";
my $item = $cal->Items(304);
#outkeys ($item);

# now get an Excel object and input the info;

my $xl = Win32::OLE->new('Excel.Application');
$xl->{Visible} = 1;
my $book = $xl->WorkBooks->Add();
my $sheet = $book->Worksheets(1);
my $row = 2;
$sheet->Columns('A')->{ColumnWidth} = 30;
$sheet->Columns('B:C')->{ColumnWidth} = 15;
$sheet->Columns('D')->{ColumnWidth} = 80;
$sheet->Range("A1:D1")->{Interior}->{Color} = RGB(0,0,0);
$sheet->Range("A1:D1")->{Font}->{Color} = RGB(255, 255, 255);
$sheet->Range("A1:D1")->{Font}->{Size} = 14;
$sheet->Range("A1:D1")->{Font}->{Bold} = 1;
$sheet->Range("A1")->{Value} = "SUBJECT";
$sheet->Range("B1")->{Value} = "BEGIN";
$sheet->Range("C1")->{Value} = "END";
$sheet->Range("D1")->{Value} = "BODY";

# lets see what is in the Start key - I am looking for a date and time.

foreach (1 .. $cal->{UnReadItemCount})
{
    my $item = $cal->Items($_);
      #print $item->Subject() . "\t" if $item;
      $sheet->Range("A$row")->{Value} = $item->Subject();
    my $start = $item->{Start};
    #print $start->Date(DATE_LONGDATE) . " " . $start->Time() . "\t" if
$start;
      $sheet->Range("B$row")->{Value} = $start;#=
$start->Date(DATE_LONGDATE) . " " . $start->Time()  if $start;
      my $end = $item->{End};
      #print $end->Date(DATE_LONGDATE) . " " . $end->Time() . "\n" if $end;
      $sheet->Range("D$row")->{Value} = $item->Body();
      $sheet->Range(sprintf"C%d", $row++)->{Value} =
$end;#->Date(DATE_LONGDATE) . " " . $end->Time()  if $end;
}
#my $subject = $item->Subject();
#print $subject . "\n";
#my $iteration = 1;

#while ($cal->Items($iteration))
#{
#   print $cal->Items($iteration)->Subject() . "\n";
#   $iteration++;
#}








sub outkeys
{
   my $hashref = $_[0];
   print "$_ = $hashref->{$_}\n" foreach sort keys %{$hashref};
}
 
 
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 17, 2003 7:37 AM
To: perl-win32-gui-users@lists.sourceforge.net
Subject: [perl-win32-gui-users] Outlook - list all folders
 
 
Does anyone have any examples of how to list all the folder names for a
particular Outlook profile? 
I'm looking at using Win32::OLE but can't figure out how to list ALL folder
names. 
Any help would be appreciated. 
Thanks! 
------------------------------------------------------------
This e-mail may be privileged and/or confidential, and the sender does not
waive any related rights and obligations. Any distribution, use or copying
of this e-mail or the information it contains by other than an intended
recipient is unauthorized. If you received this e-mail in error, please
advise me (by return e-mail or otherwise) immediately. 

Ce courrier électronique est confidentiel et protégé. L'expéditeur ne
renonce pas aux droits et obligations qui s'y rapportent. Toute diffusion,
utilisation ou copie de ce message ou des renseignements qu'il contient par
une personne autre que le (les) destinataire(s) désigné(s) est interdite. Si
vous recevez ce courrier électronique par erreur, veuillez m'en aviser
immédiatement, par retour de courrier électronique ou par un autre moyen.

============================================================

- This message (including any attachments) contains confidential information
intended for a specific individual and purpose, and is protected by law.  -
If you are not the intended recipient, you should delete this message and
are hereby notified that any disclosure, copying, or distribution of this
message, or the taking of any action based on it, is strictly prohibited.

Reply via email to