Problems sending a multiple recipient outlook mail from Notes.

I have an action button on a form in Lotus Notes that creates an outlook mail message, assigns values from the document to the To, Subject, and Body fields and sends it.  It works fine if I give it one name to send to.  If I try to give it multiple recipients it gives the following error:

OutILib.dll: Outlook does not recognize one or more names.

The names are spelled correctly and they are valid in Outlook.  How do I tell Outlook that I want the message to go to multiple people?  I am pulling the names from a SendTo field on the current document.  Here is the code:

Sub CreateOutlookMsg (doc As NotesDocument)
     Dim Sendnames As Notesitem
     Set Sendnames = doc.GetFirstItem("SendTo")
 'Get an outlook application object
     Set objSession = CreateObject("Outlook.Application")
'Create a new message
     Set objMessage= objSession.CreateItem(olMailItem)
'Set the subject and message fields
     cnumber = doc.ComplaintNumber(0)
     createdby = doc.Author(0)
'Set the SendTo Fields on the
     recips = Sendnames.Text
     Subject$ = "New Suspected Adverse Drug Reaction report  (THIS IS A TEST)"
     Message$ = "A new report has been submitted by " & createdby & _
     " for record " & cnumber & "."
     Set objRecipient = objMessage.Recipients.Add (recips)
     objMessage.subject = Subject$
     objMessage.Body = Message$
     Call objMessage.Send()
End Sub

Thanks for any help you can provide!
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.

Sammi110599Author Commented:
Edited text of question.
Hi sammy !

Try the same thing manually by adding multiple recipients.  If you succeed then look into your code.

I guess item.text gives the list values separated by semicolons.  This may be a problem with Outlook.  Try replacing these semicolons with commas and send the memo.

All the best.

Sammi110599Author Commented:

Per your suggestion, I manually added the names to an Outlook message in the same format they are being passed in the script.  That worked but Outlook checks the names and re-formats them based on what is in the Outlook address book anyway.  I then hard-coded the 'recips' variable as a literal string with the names separated by commas. e.g. "Joe Blow, Bob Jones, Jane Doe"  This gave me the same error.  Finally I tried giving the 'recips' variable another literal string with the names formatted the way Outlook formats them.  i.e.  "Jones Bob CV USAT EXC" (our organizational stuff).  That gave me the same error.

Any other ideas?

FYI:  I did try passing item.Values to the recipients field like this:

Set Sendnames = doc.GetFirstItem("SendTo")
recips = Sendnames.Values
Set objRecipient = objMessage.Recipients.Add (recips)

This results in an error on the "Set objRecipient..." line that says "Automation object argument type mismatch".  I assume its looking for text?

Again, thanks for your help.
Sammi110599Author Commented:
I solved it!!

First, I changed the 'Sendnames' object reference variable to 'Item'(don't know why this helped but it seemed to).  I then put the "Set objRecipient = ..." line in a ForAll loop.  This goes through each value in the 'SendTo' field and adds it as a recipient to the Outlook message.  Here is the code:

Forall n In Item.Values
          Set objRecipient = objMessage.Recipients.Add (n)
     End Forall

Thanks for your help earlier!
Hi Sammy !

Points ?


Cancel ?


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
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
Lotus IBM

From novice to tech pro — start learning today.