Here is the complete script. I'm running it using ActiveState ver 5.6.1 on NT 4.0 with Exchange Server 5.5.
#!\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;
I hope this thread is still alive...
Chris

In reply to Re: From VB to Perl by ChrisR
in thread From VB to Perl by ChrisR

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.