Here is the last feeble attempt:

#!\perl\bin\perl.exe -w
use strict;
use Win32::OLE; 
use Win32::OLE::Const; 

my $DEBUG_FLAG = 1; # set it to zero for real job 
#names have been changed to protect the innocent
my $server = "servername"; 
my $fname = "Firstname"; 
my $lname = "Lastname"; 
my $alias = "Alias";

# Necessary for MAPI component 
Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE); 

# Do this rather than 'use' as that interferes with the OLE Initialize code 
my $CDO_CONST = Win32::OLE::Const->Load('Microsoft CDO.*Library'); 

my $MAPI = Win32::OLE->new('MAPI.Session'); 
die "Could instantiate MAPI Session: " . Win32::OLE::LastError() if (!
defined($MAPI)); 

my %LogonParms = ( 'ProfileInfo' => "$server\n$alias" ); 

$MAPI->logon(\%LogonParms); 
die Win32::OLE::LastError() if (Win32::OLE::LastError()); 
print "USER: " . $MAPI->{CurrentUser}->Value . "\n"; 


my $Contactsfolder =
$MAPI->GetFolder($MAPI->{Inbox}->{Fields}->Item(0x36D10102),$MAPI->{Inbox}->
{StoreID}); 

my $contacts = $Contactsfolder->{Messages}; 
my $ncon = $contacts->{'Count'};
print "\tContacts - $ncon\n"; 

my $con; 
my $field1;
my $field2;
my $email1;

for my $ii (1 .. $ncon)
{ 
    $con = $contacts->Item($ii); 

    print "$ii - $con->{'FullName'}\n"; 
    print "email is $con->{0x8083}\n"; 
    print "email is $con->{'0x8083'}\n"; 
    $field1 = "{0420060000000000C000000000000046}";
    $field2 = "0x8083";
    print "email is $con->{$field1 . $field2}\n"; 
    print "email is $con->{'Email1Address'}\n";     
#no matter what I try here I always get the contact's display name
} 
exit;

-----Original Message-----
From: Tim Johnson [mailto:[EMAIL PROTECTED]
Sent: Friday, July 11, 2003 11:25 AM
To: 'Chris Rogers'; [EMAIL PROTECTED] Org (E-mail)
Subject: RE: Perl and Exchange Server



Maybe it would help if you gave us what you've tried?

-----Original Message-----
From: Chris Rogers [mailto:[EMAIL PROTECTED]
Sent: Friday, July 11, 2003 8:24 AM
To: [EMAIL PROTECTED] Org (E-mail)
Subject: Perl and Exchange Server


I have been trying for some time to get at the contacts in a mailbox on
exchange server 5.5.  I have been using Win32::OLE with CDO.  I can get the
contacts folder, the count of items in it, and even the name of each contact
but I can't seem to get at any of the fields.  I have found many examples in
VB that use the outlook object model to do this but I need to get the data
from the server without outlook.  All my attempts at this have failed
miserably.  I have tried to understand the documentation on MSDN however
there are no specific examples for getting the contacts from the server.
All examples I have found deal with the contacts from the client not the
server and the few I found written in perl don't seem to work at all.  Since
this is generally an Microscrap question, I have posted numerous times to
the MS newsgroups for exchange with no responses.  If someone can give me an
example or point me in the right direction, I would be eternally grateful.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to