I have an example that I've been told works, by a person that I helped a few
years ago. I don't have Lotus Notes installed, so I have not personally
tested it.
This cmdSendEmail_Click() procedure was for a command button named
"cmdSendEmail" on a bound form. Lotus Notes apparently requires multiple
recipients to be submitted as an array, thus the use of the Split function,
as shown in this line of code:
Call doc.replaceitemvalue("SendTo", Split(strRecipients, ","))
Here was his code module:
From: {Name Removed}
To: Tom Wickerath
Sent: Friday, February 04, 2005 9:29 AM
Subject: Fixed it!!!!!!!!!!!!!!!
Tom,
I tried another route and it fixed the problem. I can now send the string
of addresses!! I've enclosed the completed code for this "little" email
detail!!!!!!!!!
Note the new module on the end. Your help has been invaluable. Thanks so
much!!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Option Compare Database
Option Explicit
Private Sub cmdSendEmail_Click()
On Error GoTo ProcError
If Me.Dirty Then
Me.Dirty = False
End If
Dim strRecipients As String
Dim strBody As String
Dim SendTo As String
Dim strAttachpath As String
Dim Session As Object
Dim db As Object
Dim doc As Object
Dim rtitem As Object
Dim tmp As Object
Set Session = CreateObject("Notes.Notessession")
Set db = Session.GetDatabase("", "")
Call db.OPENMAIL
strRecipients = BulkEmail()
strAttachpath = "s:\ECR Temp\LotusNotus ECN Report.rtf"
Set doc = db.CreateDocument
Set rtitem = doc.CreateRichTextItem("body")
DoCmd.OutputTo acOutputReport, _
"LotusNotus ECN Report", acFormatRTF, _
strAttachpath, False
strBody = _
"THIS IS ONLY A TEST. Please reply so I know you got this. " & _
"I am testing an auto email feature of the new ECR DB. " & _
"You may be recieving more than one of these. " & _
"Thanks for your help!!"
Call rtitem.AppendText(strBody)
Call rtitem.AddNewLine(2)
Set tmp = rtitem.EmbedObject(1454, "", strAttachpath)
Call doc.replaceitemvalue("SendTo", Split(strRecipients, ","))
Call doc.replaceitemvalue("Subject", "NEW ECN")
Call doc.Send(False)
MsgBox ("Report has been sent!")
ExitProc:
'Cleanup
On Error Resume Next
Set Session = Nothing
Set db = Nothing
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in cmdSendEmail_Click Event Procedure..."
Resume ExitProc
End Sub
Function BulkEmail() As String
On Error GoTo ProcError
'Return a concatenated string from individual records in a recordset
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim strOut As String
Dim lngLen As Long
Const conSEP = ", "
Set db = CurrentDb()
Set qdf = db.QueryDefs("quniAllRecipients")
qdf![[Forms]![ECN Form]![ECR Number]] = [Forms]![ECN Form]![ECR Number]
Set rs = qdf.OpenRecordset(dbOpenSnapshot)
With rs
Do While Not .EOF
strOut = strOut & !Recipient & conSEP
.MoveNext
Loop
End With
lngLen = Len(strOut) - Len(conSEP)
If lngLen > 0 Then
BulkEmail = Left$(strOut, lngLen)
End If
ExitProc:
'Cleanup
If Not rs Is Nothing Then
rs.Close: Set rs = Nothing
End If
Set qdf = Nothing
Set db = Nothing
Exit Function
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in procedure BulkEmail..."
Resume ExitProc
End Function
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Tom Wickerath
Microsoft Access MVP
https://mvp.support.microsoft.com/profile/Tom
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________