Depois de muita experimentação, encontrei uma solução usando o seguinte script Perl:
#!/usr/bin/perl
use strict;
use warnings;
use Win32::OLE qw(in with);
$Win32::OLE::Warn = 2;
use Win32::OLE::Variant; # to get Date scalar
my $olFolderContacts = 10; # = olFolderContacts
my $outlook;
eval {
$outlook = Win32::OLE->GetActiveObject('Outlook.Application');
};
die "$@\n" if $@;
if (!defined $outlook) {
$outlook = Win32::OLE->new('Outlook.Application')
or die "Oops, cannot start Outlook: ", Win32::OLE->LastError, "\n";
}
my $mapi = $outlook->GetNamespace('MAPI'); # see class NameSpace
my $searchname = "@ARGV";
my $contacts = $mapi->GetDefaultFolder($olFolderContacts); # (FolderType As OlDefaultFolders) As Folder
# also olFolderCalendar, olFolderDeletedItems, olFolderDrafts, olFolderInbox, olFolderSuggestedContacts, ...
my @found;
for my $contact (in $contacts->{Items}) {
my $name = $contact->{"FullName"};
if ($name =~ /\b${searchname}\b/i) { push(@found, $contact); }
}
if (!@found) { die "Contact '$searchname' not found\n"; }
if (@found>1) {
warn "Found multiple contacts matching '$searchname':\n";
for (@found) { my $name = $_->{"FullName"}; warn "$name\n"; }
exit 1;
}
my $contact = $found[0];
my $name = $contact->{"FullName"};
warn "Found '$name'\n";
$contact->Display;