Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA/Lotus Notes Send to multiple recipients 1

Status
Not open for further replies.

RP1America

Technical User
Aug 17, 2009
221
US
I have a sub that generates a Lotus Notes email via VBA. Everything works great when sending to only one recipient. How can I send to multiple recipients?

Code:
Sub EmailCashDetailReportLotusNotes()

    Dim Maildb As Object
    Dim MailDoc As Object
    Dim Body As Object
    Dim Session As Object
'Start a session of Lotus Notes
    Set Session = CreateObject("Lotus.NotesSession")
'This line prompts for password of current ID noted in Notes.INI
    Call Session.Initialize
'or use below to provide password of the current ID (to avoid Password prompt)
    'Call Session.Initialize("<password>")
'Open the Mail Database of your Lotus Notes
    Set Maildb = Session.GETDATABASE("", "names.nsf")
    If Not Maildb.IsOpen = True Then Call Maildb.Open
'Create the Mail Document
    Set MailDoc = Maildb.CREATEDOCUMENT
    Call MailDoc.REPLACEITEMVALUE("Form", "Memo")
'Set the Recipient of the mail
    [highlight #FCE94F]Call MailDoc.REPLACEITEMVALUE("SendTo", "Insert recipient here")[/highlight]
'Set subject of the mail
    Call MailDoc.REPLACEITEMVALUE("Subject", "Insert Subject here")
'Create and set the Body content of the mail
    Set Body = MailDoc.CREATERICHTEXTITEM("Body")
    Call Body.APPENDTEXT("Insert Body text here")
'Example to create an attachment (optional)
    Call Body.ADDNEWLINE(2)
    Call Body.EMBEDOBJECT(1454, "", "I:\RP\attachmentfile.xls", "Attachment")
'Send the document
'Gets the mail to appear in the Sent items folder
    Call MailDoc.REPLACEITEMVALUE("PostedDate", Now())
    Call MailDoc.SEND(False)
'Clean Up the Object variables - Recover memory
    Set Maildb = Nothing
    Set MailDoc = Nothing
    Set Body = Nothing
    Set Session = Nothing
    
End Sub
 
Good. Just for the record do you know which version of Notes you have been talking to?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top