Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Venerable Monks, I'm trying to send email through Lotus Notes with multiple SendTo, CopyTo and/or BlindCopyTo recipients with code such as this:
#!perl -w use strict; use Win32::OLE; my $servername = 'NOTES1/CORPSERVER'; #your server name here # my $db_path = 'mail\ltcrepor.nsf'; #your mail database here # my $pw = 'LTCREPORTS'; #your password here my $db_path = 'mail\dbase.nsf'; #your mail database here my $pw = 'password'; #your password here my $Notes = Win32::OLE->new('Lotus.NotesSession') or die "Can't get NotesSession object.\n"; $Notes->Initialize($pw); my ($Version) = ($Notes->{NotesVersion} =~ /\s*(.*\S)\s*$/); my $User = $Notes->{UserName}; my $Platform = $Notes->{Platform}; my $Database = $Notes->GetDatabase($servername,$db_path) or die "Cannot access database"; my $Document = $Database->CreateDocument; $Document->AppendItemValue ("Form", "Memo"); # ***MULTIPLE RECIPIENTS SHOULD BE AN ARRAY OF STRING ELEMENTS*** my @recipients = ('cat@hat.com', 'rush@gasbag.org'); print @recipients; $Document->AppendItemValue ("SendTo", @recipients); $Document->AppendItemValue ("Subject", "Lotus Notes email from Perl sc +ript"); my $Filename = "C:\\OLEnotes.txt"; my $Body = $Document->CreateRichtextItem('Body'); $Body->AppendText(<<"EOT"); This here is the body text of the email. Kind regards, Mary EOT $Body->EmbedObject (1454, "", $Filename, "Attachment"); $Document->Send(0);
That code yeilds this error message:
Win32::OLE(0.1403) error 0x8002000e: "Invalid number of parameters" in METHOD/PROPERTYGET "AppendItemValue" at this_sends_lotus_email. +pl line 30 OLE exception from "NotesDocument": No recipient list for Send operation Win32::OLE(0.1403) error 0x80041048 in METHOD/PROPERTYGET "Send" at this_sends_lotus_email.pl line 54
Referring to THIS LINK, multiple recipients must be in an array of string elements. How can I accomplish this in Perl? Humbly yours, Bukharik

Replies are listed 'Best First'.
Re: Lotus Email: Multiple Recipients
by robobunny (Friar) on Jun 12, 2002 at 19:45 UTC
    since it's called "AppendItemValue", maybe you need to call it multiple times?
    foreach my $rcpt (@recipients) { $Document->AppendItemValue ("SendTo", $rcpt); }
      very logical suggestion. i tried similar, which didn't work. i also tried a single string with comma-separated email addresses. in both cases, the email goes out to the first recipient and ignores the rest.