Category: | Win32 Stuff; OLE Automation |
Author/Contact Info | Max Maischein (Corion) corion@informatik.uni-frankfurt.de |
Description: | This is a small example on how to use the MS Outlook object model from within Perl (under Win32 of course) to extract contacts data. If you have the Outlook object model chart at hand, it's easy to automate other tasks such as sending mail or creating contacs as well. This snippet needs Outlook to be open and the Contacts view must be active, because I was too lazy to drill my way down from Outlook->Application to the Contacts view.
Update:I added the missing <code> tags myself. Even more stupid I am ... Update 2:Some documentation - the 069 is my local area code. |
#!/usr/bin/perl -w use strict; use Win32::OLE; my @PhoneProperties = ( "Business2TelephoneNumber", "BusinessFaxNumber", "BusinessTelephoneNumber", "CarTelephoneNumber", "Home2TelephoneNumber", "HomeTelephoneNumber", "ISDNNumber", "MobileTelephoneNumber", "OtherFaxNumber", "OtherTelephoneNumber", "PrimaryTelephoneNumber", ); my $outlook; $outlook = Win32::OLE->new('Outlook.Application'); my $activeexplorer; $activeexplorer = $outlook->ActiveExplorer; print $activeexplorer->Caption,"\n"; my $items = $activeexplorer->CurrentFolder->Items; print $items->Count,"\n"; my $linenumber = 1; print "NR;NAME;TELNUM\n"; my $Kontakt; my $PhoneProp; my $ItemIndex = 1; while ($ItemIndex <= $items->Count) { $Kontakt = $items->item($ItemIndex); foreach $PhoneProp (@PhoneProperties) { my $number = $Kontakt->{"$PhoneProp"}; if ($number) { # Prefix local area code unless an area code # is already given if ($number !~ /^0/) { $number = "069$number" }; $number =~ s/ +//g; $number =~ s/-+//g; print $linenumber++, ";", $Kontakt->FullName,";'$number\n"; #print "$number=", substr( $Kontakt->FullName, 1, 15 ),"\n"; }; }; $ItemIndex++; }; |
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Extract Outlook Telephone Numbers
by dze27 (Pilgrim) on Mar 03, 2001 at 01:49 UTC | |
Re: Extract Outlook Telephone Numbers
by jlf (Scribe) on Mar 08, 2002 at 22:29 UTC |
Back to
Code Catacombs