Sending an Email via Lotus Notes

By Ken Reay

For support please ask in the microsoft.public.access.interopoledde newsgroup

The following code snippet should send an Email via Lotus Notes from within Access without using SendObject

Dim notesdb As Object
Dim notesdoc As Object
Dim notesrtf As Object
Dim notessession As Object
Set notessession = CreateObject("Notes.Notessession")
Set notesdb = notessession.getdatabase("", "")
Call notesdb.openmail
Rem make new mail message
Set notesdoc = notesdb.createdocument
Call notesdoc.replaceitemvalue("Sendto", strSupportEMail)
Call notesdoc.replaceitemvalue("Subject", "Problem Report")
Set notesrtf = notesdoc.createrichtextitem("body")
Call notesrtf.appendtext("Problem Report")
Call notesrtf.addnewline(2)
Rem attach Error Report doc
's = ActiveDocument.Path + "\" + ActiveDocument.Name
Call notesrtf.embedObject(1454, "", strCurrentPath, "Mail.rtf")
Rem send message
Call notesdoc.Send(False)
Set notessession = Nothing

GB located the following snippet for passing the password.

Dim MailPassword As String
Dim lnSession As NotesSession
Set lnSession = CreateObject("Lotus.NotesSession")
Call lnSession.Initialize(MailPassword)

Some code to start Lotus Notes automatically and some alternatives to the above code can be found at Automated Email w/ Lotus Notes

[ Email FAQ ]