Sending MAPI email with PERL in ClearQuest

Here's what I am using for my code, I want to be able to add multiple people on the TO: line CC: line and resolve them:  Please help!

  $myvar = "Resolved Name";
   use Win32::OLE;
   my $mapisession = Win32::OLE->new("MAPI.Session")
        or die "Failed to create a new MAPI Session!";

        # Logon to server
   my $res = $mapisession->Logon("OUTLOOK");
        die "Could not log on to exchange server!" if ($res);
   # Create a new message
   my $msg = $mapisession->Outbox->Messages->Add();
   # Add the recipient and resolve the address
       my $recipient = $msg->Recipients->Add();
        $recipient->{Name} = $myvar;
        # Add your text
        $msg->{Subject} = "Fat Client Test";
        $msg->{Text} = qq/
                Email test ....
                will this work?
                        Fred and Barney
        # Send the email
        $msg->Send(0, 0, 0);
        # Log off
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

my $recipient2 = $msg->Recipients->Add();
$recipient2->{Name} = $myvar2;
... and so on for more recipients

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mschwadeAuthor Commented:
Thank you that worked, but is there anyway to make the 2nd recpient show up on the CC line?

mschwadeAuthor Commented:

I tried this, but didn't work..

      $rcount = 1;
      foreach $user_name (@users) {
      recipientobj = "recipient$rcount";
      my $recpientobj = $msg->Recipients->Add();
      $recipientobj->{Name} = $user_name;
      $rcount = $rcount+1;
According to this:
you need to set the type to 2 for cc.  I'm not sure how to do that, but try this:
    my $recipient2 = $msg->Recipients->Add($myvar2, undef, 2);

To add from an array
foreach my $uname (@users) {
    my $recip = $msg->Recipients->Add();
    $recip->{Name} = $uname;

mschwadeAuthor Commented:
I figured out the CC by the code below.. But Adam, remember in adding from an array, the my $recip still needs to be different each time through the loop or it doesn't work, for example my $recip, my $recip2, etc..

my $recipient2 = $msg->Recipients->Add();
$recipient2->{Name} = $uname;
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.