Adapted from a similar script by Rob Hanson on perl-win32-users – hope this helps.


use strict;

use Win32::OLE;


# use existing instance if Outlook is already running, or launch a new one

my $ol;

eval {$ol = Win32::OLE->GetActiveObject('Outlook.Application')};

die "Outlook not installed" if $@;

unless (defined $ol) {

  $ol = Win32::OLE->new('Outlook.Application', sub {$_[0]->Quit;})

    or die "Oops, cannot start Outlook";



my $mailbox = seekFolder($ol->Session, 'Mailbox - Doe, John');




sub seekFolder {

  my $obj = shift;

  my $target = shift;


  for (my $i = 1; $i <= $obj->Folders->Count; $i++) {

    if ( $obj->Folders->Item($i)->Name eq $target ) {

      return $obj->Folders->Item($i);






sub listFolders {

            my $parent = shift;

            for (my $t = 1; $t <=$parent->Folders->Count;$t++){

            print $t . ": " . $parent->Folders->Item($t)->Name . "\n";




-----Original Message-----
From: []
Sent: 17 October 2003 13:37
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.

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.