I have a script that sends mail based on a list of names in a document. The function that does the mail also creates new documents based on transactions entered by the user. Kind of a child document...
The error I received "Unable to send Mail, No match found in address book" is valid because there was one person in the list who is no longer listed in the address book. But when it presented the error to the User, it also apparrently dropped out of the function it was in, without processing the other names and without processing the child doc.
I'm wondering if I can add some error handling so that the code can handle invalid names in the list. If I can trap for the error, I can have the code mail the Admin of the database about the missing name and (more importantly) let the user continue their work.
Function MailPurchAlert(Amount As Variant, note As notesdocument, Action As String)
Dim workspace As New NotesUIWorkspace
Dim session As New notessession
Dim db As NotesDatabase
Set db = session.CurrentDatabase
Dim item As NotesItem
GROUP = note.MAILTO
Set item = note.GetFirstItem("MAILTO")
FUND = note.Fund(0)
SETTLEDATE = Cstr(note.Date(0))
Purchase = Cstr(note.Purchase(0))
Cancel = Cstr(note.Cancel_1(0))
PurchaseOld = Cstr(note.Purchase_1(0))
CancelOld = Cstr(note.Cancel_1(0))
If Isempty(GROUP) Then
' do nothing
'Forall a In note.MAILTO
' Set item = note.getfirstitem("MAILTO")
Set SendTo = New NotesName(a)
Set NotifyDoc = New NotesDocument(Db)
NotifyDoc.Form = "Memo"
NotifyDoc.SendTo = SendTo.Abbreviated
NotifyDoc.Subject = "A CHANGE to a Large $ Trade Notification"
Set Body = New NotesRichTextItem(NotifyDoc, "Body")
Msg = "Please note that the " & FUND & " fund will have a large dollar " & Action & " trade in the amount of "
Msg = Amount & " on Settlement Date of " & SETTLEDATE & ". This represents a change in what was reported to you."
Body.AppendText "To view more information regarding this large dollar trade notification, please review the "
Body.AppendText "Summary page of the Large $ Trade Notification database. "
Body.AppendText "Click here to go to the document: "
Body.AppendDocLink Note, "Large Dollar"
Body.AppendText "For questions regarding this trade notice, please contact the individual that submitted this notice via the Large Dollar Trade Notification database."
Body.AppendText " For questions about the database, please contact your Admin."
For x=0 To Ubound(item.values)
Print "Mail Send to: "&Cstr(item.values(x))