SteveBriscoe
New member
- Local time
- Today, 14:43
- Joined
- May 21, 2009
- Messages
- 7
I am trying to send to multiple email addresses taken from multiple rows in a table using lotus notes. I have the lotus notes part of it working, I think it's the retrieving and sending to multiple rows/addresses I am having the problem with.
I have a table called "Subscriptions" and within there, a field called product and a field called "subscriber_email_address". The way the form works if you select a product on the form and click send to send an email to all users subscribed to that product (taken from the subscriptions table). My code so far, and apologies if it's glaringly obvious but I am by no means an expert user...
Dim MyRS2 As DAO.Recordset
Set MyDB2 = CurrentDb()
'retrieve list of subscribers from the subscriptions table...
Set MyRS2 = MyDB.OpenRecordset("Select FROM Subscriptions where product_name = '" & Forms!Add_New_Article.Combo2.Value & "'", dbOpenDynaset)
'Start the code to generate the emails...
Dim Product As String
Dim notesdb As Object
Dim notesdoc As Object
Dim notesrtf As Object
Dim notessession As Object
Set notessession = CreateObject("Notes.Notessession")
Call notesdb.openmail
'Start the loop to email each subscriber...
Do While Not MyRS2.EOF
Set notesdb = notessession.getdatabase("", "")
Set notesdoc = notesdb.createdocument
Call notesdoc.replaceitemvalue("Sendto", "" & subscriber_email_address)
Call notesdoc.replaceitemvalue("Subject", "" & Text0.Value)
Set notesrtf = notesdoc.createrichtextitem("body")
Call notesrtf.appendtext("" & Text4.Value)
'Send message...
Call notesdoc.Send(False)
Set notessession = Nothing
MyRS2.MoveNext
Loop
DoCmd.Close
Else
DoCmd.Close
End If
I have a table called "Subscriptions" and within there, a field called product and a field called "subscriber_email_address". The way the form works if you select a product on the form and click send to send an email to all users subscribed to that product (taken from the subscriptions table). My code so far, and apologies if it's glaringly obvious but I am by no means an expert user...
Dim MyRS2 As DAO.Recordset
Set MyDB2 = CurrentDb()
'retrieve list of subscribers from the subscriptions table...
Set MyRS2 = MyDB.OpenRecordset("Select FROM Subscriptions where product_name = '" & Forms!Add_New_Article.Combo2.Value & "'", dbOpenDynaset)
'Start the code to generate the emails...
Dim Product As String
Dim notesdb As Object
Dim notesdoc As Object
Dim notesrtf As Object
Dim notessession As Object
Set notessession = CreateObject("Notes.Notessession")
Call notesdb.openmail
'Start the loop to email each subscriber...
Do While Not MyRS2.EOF
Set notesdb = notessession.getdatabase("", "")
Set notesdoc = notesdb.createdocument
Call notesdoc.replaceitemvalue("Sendto", "" & subscriber_email_address)
Call notesdoc.replaceitemvalue("Subject", "" & Text0.Value)
Set notesrtf = notesdoc.createrichtextitem("body")
Call notesrtf.appendtext("" & Text4.Value)
'Send message...
Call notesdoc.Send(False)
Set notessession = Nothing
MyRS2.MoveNext
Loop
DoCmd.Close
Else
DoCmd.Close
End If