Avatar of pratigan
pratigan
Flag for United States of America asked on

multivalue send mail field not working with more than 1 recipient in the field

Many questions and answers for this one, but none that pin point what's going on.
I have an agent that runs daily @ 12 noon to remind recipients that they have issues outstanding.  The view that is referenced has an assigned field that can contains multi names.  Here is what I have for the auto agent mail send.
Sub Initialize
      Dim session As notessession
      Dim doc As notesdocument
      Dim curdoc As notesdocument
      Dim db As notesdatabase
      Dim v As NotesView
      Dim rtitem As NotesRichTextItem
      
      Set session = New notessession
      Set db = session.Currentdatabase
      Set doc = New notesdocument (db)
      Set v = db.GetView( "OpenIRs5")
      
      Set curdoc = v.GetFirstDocument
      Do Until curdoc Is Nothing
            doc.principal= "eStar Open IR Auto Notification Monitor"
            doc.Subject = "Assigned IR over 5 days old Pending Your Review."
            doc.Remark = "This notification is autogenerated.  Please do not reply to this email."
            Set rtitem = New NotesRichTextItem( doc, "Body" )
            Call rtitem.AppendText( "This is a Daily Notification Process indicating you have an open IR older than 5 days that Requires your attention. " + Chr(13) + "Please Open, Review and Update the IR." + Chr(13) + "A Final Cause and Resolution are Required. " + Chr(13) + "Thank You !" + Chr(13) + "Open IR Document Link  ->  " )
            Call rtitem.AppendDocLink( curdoc, doc.Subject( 0 ) )
            Call doc.send(False,curdoc.assigned)
            Set curdoc = v.GetNextDocument( curdoc )
      Loop
End Sub

if there is one name in the assigned field on the form then the email gets sent no problem.  If there are more than 1 name I get an error saying no match found in the address book.  The assigned field is multivalue separated by semicolon.  This agent go through each doc in the view and sends an email to the assigned recipients.
What am I missing ???
Thank You !
Paul
Lotus IBM

Avatar of undefined
Last Comment
pratigan

8/22/2022 - Mon
mbonaci

Hi pratigan,
have you tried to put elements of Variant curdoc.assigned to string array and pass it to Send method?
mbonaci

Like this:

Dim tmpArr() As String
Dim i As Integer

i = 0
Forall elem In curdoc.assigned
      Redim Preserve tmpArr( i ) As String
      tmpArr( i ) = CStr( elem )
      i = i + 1
End Forall

...
Call doc.Send( False, tmpArr )

Hope this helps,
Mb¤
pratigan

ASKER
Hello MB... I didn't try that, I figured as a multi value field separated by semicolon that it would see it as a multi email lisiting and verify the names separately.
Now the question becomes where in the body of this script would I put that, inside the loop.  I'm thinking like this.
Sub Initialize
      Dim session As notessession
      Dim doc As notesdocument
      Dim curdoc As notesdocument
      Dim db As notesdatabase
      Dim v As NotesView
      Dim rtitem As NotesRichTextItem
      
      Set session = New notessession
      Set db = session.Currentdatabase
      Set doc = New notesdocument (db)
      Set v = db.GetView( "OpenIRs5")
      
      Set curdoc = v.GetFirstDocument
      Do Until curdoc Is Nothing
            Dim tmpArr() As String
            Dim i As Integer
            
            i = 0
            Forall elem In curdoc.assigned
                  Redim Preserve tmpArr( i ) As String
                  tmpArr( i ) = Cstr( elem )
                  i = i + 1
            End Forall
            
            
            
            
      '      doc.sendto=curdoc.assigned
            doc.principal= "eStar Open IR Auto Notification Monitor"
            doc.Subject = "Assigned IR over 5 days old Pending Your Review."
            doc.Remark = "This notification is autogenerated.  Please do not reply to this email."
            Set rtitem = New NotesRichTextItem( doc, "Body" )
            Call rtitem.AppendText( "This is a Daily Notification Process indicating you have an open IR older than 5 days that Requires your attention. " + Chr(13) + "Please Open, Review and Update the IR." + Chr(13) + "A Final Cause and Resolution are Required. " + Chr(13) + "Thank You !" + Chr(13) + "Open IR Document Link  ->  " )
            Call rtitem.AppendDocLink( curdoc, doc.Subject( 0 ) )
            'Call doc.send(False,curdoc.assigned)
            
            Call doc.Send( False, tmpArr )
            
            Set curdoc = v.GetNextDocument( curdoc )
      Loop
End Sub
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes
mbonaci

Yes, it's fine.
Does it work?
ASKER CERTIFIED SOLUTION
mbonaci

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
pratigan

ASKER
ok.. here's what I have:
Sub Initialize
      Dim session As notessession
      Dim doc As notesdocument
      Dim curdoc As notesdocument
      Dim db As notesdatabase
      Dim v As NotesView
      Dim rtitem As NotesRichTextItem
      Dim item As NotesItem
      
      Set session = New notessession
      Set db = session.Currentdatabase
      Set doc = New notesdocument (db)
      Set v = db.GetView( "OpenIRs5")
      
      Set curdoc = v.GetFirstDocument
      Do Until curdoc Is Nothing
            Dim tmpArr() As String
            Dim i As Integer
            
            Set item = curdoc.GetFirstItem( "assigned" )   'instead of Forall loop
            item.IsNames= True
            Call doc.CopyItem( item, "SendTo" )
            
      '      doc.sendto=curdoc.assigned
            doc.principal= "eStar Open IR Auto Notification Monitor"
            doc.Subject = "Assigned IR over 5 days old Pending Your Review."
            doc.Remark = "This notification is autogenerated.  Please do not reply to this email."
            Set rtitem = New NotesRichTextItem( doc, "Body" )
            Call rtitem.AppendText( "This is a Daily Notification Process indicating you have an open IR older than 5 days that Requires your attention. " + Chr(13) + "Please Open, Review and Update the IR." + Chr(13) + "A Final Cause and Resolution are Required. " + Chr(13) + "Thank You !" + Chr(13) + "Open IR Document Link  ->  " )
            Call rtitem.AppendDocLink( curdoc, doc.Subject( 0 ) )
            'Call doc.send(False,curdoc.assigned)
            
            Call doc.Send( False )
            
            Set curdoc = v.GetNextDocument( curdoc )
      Loop
End Sub

I'm still getting the Unable to send mail no name found in the address book,,,,..... I'm just thinking outloud now... I'm running off local and that probably why.  I may need to move it to a server that has address book access.  So, I moved the code to the development server and Awesome... it worked like a charm.............. Thank You Very Much !!!