This is a work in progress. I havent finished all I want to do with it yet.

Todo:
1. Speed up search by using addrfiler object
2. Make addr single line address display with tele, st addr, city, country
3. Find the correct addrlist without having to use a index to it. (the -n arg)

To use it you will have to put your own password in the login() method.
If you have changed the default profile name you will have to change the 
profile name.

I use something like this.
perl -S exchaddr.pl -n 8 [-f] -s davis

The 8 is the 8th addrlist which at my installation is the shortest.

bob



Chris Wagner wrote:
Greets, does anyone know of a module or WMI/OLE method that will let u
interact with the Outlook global address list?  Or an offline copy thereof?
I want to be able to search fields for usernames and bring back all the info.







--
REMEMBER THE WORLD TRADE CENTER         ---=< WTC 911 >=--
"...ne cede malis"

00000100

_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

.


--
Bob Davis | Senior Advisory Software Developer - Applications
[EMAIL PROTECTED]
Work: 603-926-9696 x3456
Home: 603-778-0781
Aim: dad1732
Yim: rsdavis9
#!/usr/bin/perl
use strict;
use Win32::OLE; 
use Data::Dumper;
my $Session;

my $Recurs = 0;
my $Pattern = '.*';
my $AddrListNum;
my $Full = 0;

while (my $opt=shift @ARGV) {
        if ($opt =~ /^-r/i) { 
                $Recurs = 1;
        }
        if ($opt =~ /^-s/i) { 
                $Pattern = shift @ARGV; 
        }
        if ($opt =~ /^-n/i) { 
                $AddrListNum = shift @ARGV; 
        }
        if ($opt =~ /^-f/i) { 
                $Full = 1;
        }
        if ($opt !~ /^-/i) { unshift @ARGV, $opt; last; }
}
print "aln:pat:recur=$AddrListNum:$Pattern:$Recurs\n";

my $name = "Microsoft Outlook Internet Settings";

Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE) ;
die "Coinitialize error", Win32::OLE->LastError(),"\n" if 
Win32::OLE->LastError();

$Session = Win32::OLE->new('MAPI.Session');
die "Could not create a MAPI Session: $!", Win32::OLE->LastError(),"\n" if 
Win32::OLE->LastError();
$Session->Logon($name, "xxxxxx");
die "Could not login: ", Win32::OLE->LastError(),"\n" if 
Win32::OLE->LastError(); 

my $AddrLists = $Session->{AddressLists};
print "AddrLists=$AddrLists\n";

if ($AddrListNum) {
        my $AddrList = $AddrLists->Item(0+$AddrListNum);
        $Recurs = 1;
        DspAddrList($AddrList, $AddrListNum);
} else {
        for (my $i=1; $i<=$$AddrLists{Count}; $i++) {
                my $AddrList = $AddrLists->Item($i);
                DspAddrList($AddrList, $i);
        }
}


sub DspAddrList {
        my ($AddrList, $Cnt) = @_;
        my $id = sprintf "%08x", $$AddrList{ID};
        my $Name = $$AddrList{Name};
        my $AddrEntrys = $$AddrList{AddressEntries};
        print "\tAddrList$Cnt:ID:AddrEntries=$id:$Name:$$AddrEntrys{Count}\n";
        if ($Recurs) {
                for (my $i=1; $i<=$$AddrEntrys{Count}; $i++) {
                        my $AddrEntry = $AddrEntrys->Item($i);
                        my $Name=$$AddrEntry{Name};
                        my $Type=$$AddrEntry{Type};
                        my $ID=$$AddrEntry{ID};
                        my $Address=$$AddrEntry{Address};
                        my $SmtpAddr;
                        #if ($Stmt =~ /(?is)$rx/) {
                        if ($Name =~ /(?is)$Pattern/) {
                                $SmtpAddr = GetPropVal($AddrEntry, 0x39fe001e);
                                print 
"\t\tName:Index:Type:SmtpAddr=$Name:$i:$Type::$SmtpAddr\n";
                                print "\t\t\tAddress=$Address\n";
                                #print "\t\t\tID=$ID\n";
                                if ($Full) {
                                        my $Aef = $$AddrEntry{Fields};
                                        for (my $i=1; $i<$$Aef{Count}; $i++) {
                                                my $Prop=$Aef->Item($i);
                                                my $Name=$$Prop{Name};
                                                my $id = sprintf "%08x", 
$$Prop{ID};
                                                my $Value=$$Prop{Value};
                                                print 
"\t\t\t$i:ID:Value=$id:$Value\n";
                                                # either method works 
                                                #       universal would work if 
array was any where in tree
                                                #       ref works only if array 
ref
                                                #if (UNIVERSAL::isa($Value, 
"ARRAY")) {
                                                if (ref($Value) eq 'ARRAY') {
                                                        print "\t\t\t\tarray 
stuff\n";
                                                }
                                        }
                                }

                        }
                }
        }

}

sub GetPropVal {
        my ($Att, $PropID) = @_;
        my $Value;
        my $Fields=$$Att{Fields};
        for (my $i=1; $i<=$$Fields{Count}; $i++) {
                my $Fld=$Fields->Item($i);
                if ($$Fld{ID} == $PropID) {
                        $Value = $$Fld{Value};
                        last;
                }
        }
        return $Value;
}

undef $Session;
print "done\n";
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to