Home > Domino Tips > Developer > LotusScript > Validating SendTo field for programmatically generated e-mails
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

LOTUSSCRIPT

Validating SendTo field for programmatically generated e-mails


Sunil Vishwakarma
08.29.2005
Rating: -3.40- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


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.


View member feedback to this tip.

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.

And finally,

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.

—Pedro F.


Do you have comments on this tip? Let us know.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
LotusScript
Extracting attachments from a Lotus Notes rich-text field
Programmatically replace the design of Lotus Notes databases
Reading a binary field in an Oracle database with LotusScript
LotusScript equivalent of @Picklist for Lotus Notes
Launch large attachments within an email from a Notes database
How to find files on a hard drive or mapped network with LotusScript
Update the ACL from the Roles view with LotusScript
LotusScript agent moves tagged spam email to junk mail folder
Create a personalized greeting for Lotus Notes database users
Fail-safe rich-text validation using LotusScript

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.

HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 1999 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts