I hope this thread is still alive...#!\perl\bin\perl.exe -w use strict; use warnings; use Win32::OLE; use Win32::OLE::Const; use Math::BigInt; # Names have been changed to protect the innocent my $server = "servername"; my $fname = "foo"; my $lname = "bar"; my $alias = "fbar"; # MAPI won't work without this Win32::OLE->Initialize(Win32::OLE::COINIT_OLEINITIALIZE); # Load the constants my $CDO_CONST = Win32::OLE::Const->Load('Microsoft CDO.*Library'); # Create a MAPI session my $MAPI = Win32::OLE->new('MAPI.Session'); die "Could instantiate MAPI Session: " . Win32::OLE::LastError() if (! + defined($MAPI)); # Create a temporary profile my %LogonParms = ( 'ProfileInfo' => "$server\n$alias" ); # Logon to the MAPI session $MAPI->logon(\%LogonParms); die Win32::OLE::LastError() if (Win32::OLE::LastError()); # Just a debug statement print "USER: " . $MAPI->{CurrentUser}->Value . "\n"; # get the Contacts folder of the active mailbox my $Contactsfolder = $MAPI->GetFolder($MAPI->{Inbox}->{Fields}->Item(0 +x36D10102),$MAPI->{Inbox}->{StoreID}); #get the contacts my $contacts = $Contactsfolder->{Messages}; # Get the number of contacts found in the folder my $ncon = $contacts->{'Count'}; # Just a debug statement print "\tContacts - $ncon\n"; my ($con, $field1, $field2, $num, $email1, $x); # Everything above this line works or at least I think it's working # Iterate through the object for my $x (1 .. $ncon) { #get the contact object (I think) $con = $contacts->Item($x); #print out the counter and the display name of the contact print "# $x - $con->{'DisplayName'}\n"; ################################################ # Each of the follwing print statements print # # out the name of the contact. I'm trying # # get the email address. Since I get the # # same output even though I'm using different# # values, I'm very confused. I may actually # # be a simple syntax error but I'm not sure. # ################################################ print "email is $con->{'Email1Address'}\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->{$field1 & $field2}\n"; $field1 = Math::BigInt->new('0x0420060000000000C000000000000046'); $field2 = "0x8083"; print "email is $con->{$field1 . $field2}\n"; print "email is $con->{$field1 & $field2}\n"; $field1 = '&H3A16001E'; $field1 =~ s/\&H/0x/x; print "email is $con->{$field1}\n"; $num = eval $field1; print "email is $con->{$num}\n"; } exit;
In reply to Re: From VB to Perl
by ChrisR
in thread From VB to Perl
by ChrisR
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |