This tip was submitted to the SearchDomino.com tip exchange by member Sunil Vishwakarma. Please let others know how useful it is via the rating scale at the end of the tip. Do you have a useful Notes/Domino tip or code to share? Submit it to our bimonthly tip contest and you could win a prize and a spot in our Hall of Fame.
Most of the time our SendMail function sends e-mails to those individuals on the server who do not exist. So here I present a LotusScript function to validate e-mail recipients.
Public Function ValidateNames(varNames As Variant) As Variant On Error Goto errorHandler ValidateNames = "" Dim varTemp As Variant Dim varCommonNames As Variant Dim i As Integer Dim strAllNames As String If Isarray(varNames) Then varNames = Fulltrim(varNames) If Ubound(varNames) >= 0 Then For i = Lbound(varNames) To Ubound(varNames) strAllNames = strAllNames & Cstr(varNames(i)) & "," Next varTemp = Evaluate(|@Unique(@Transform( @Explode("| & strAllNames & |";","); "x"; @Name([ABBREVIATE];@Trim(@NameLookup([EXHAUSTIVE];x;"FullName")) )))|) ValidateNames = Fulltrim(varTemp) End If Else varTemp = Evaluate(|@Trim(@NameLookup([EXHAUSTIVE];"| & Cstr(varNames) &|";"FullName"))|) varCommonNames = Evaluate(|@Name([ABBREVIATE];"| & Cstr(varTemp(0)) & |")|) If Isarray(varCommonNames) Then If varCommonNames(0) <> "" Then ValidateNames = varCommonNames(0) End If End If End If Exit Function errorHandler: Msgbox "Error# " & Err & " - " & Error & " at line# " & Erl ValidateNames = "" End Function
What you need to do it call the function as follows:
mailDoc.sendTo = validateNams(mailDoc.sendTo) or mailDoc.sendTo = validateNams(arrMailRecipients)
where arrMailRecipients (could be an array, avariant or a string) represents the individuals who should receive the e-mail.
If mailDoc.sendTo(0) <> "" then Call mailDoc.send(false) End If
MEMBER FEEDBACK TO THIS TIP
What happen with Internet addresses? This is OK for Lotus users but not for this e-mail address type. I would change the function and the "wrong adresses" that they contains something like "@doman.something". I would also mark like "OK" not wrong.
But I think the best form to work would be:
On error Goto ErrorMail Call doc.send(.....) exit sub ErrorMail: print error resume next
If you send a recipients' list it works for everyone except the wrong ones. The new R5 and R6 releases work fine with this at least.
Do you have comments on this tip? Let us know.