I've searched and searched this site for the answer to my problem, but can't find anything...
After lots of trial and error I've figured out how to send email from my form. I have a knowledge database and want to have users click a button to send an email to a set group of people (list of email addresses - emailAddress - in a table - tblEmail). In the email, it will automatically populate the body of the email with the different fields on the knowledge form (issue, cause, resolution, etc). This I've figured out fine. The only thing that is not working for me is populating the To: field in the email. It will only put the first email in the table. I'm sure it's something pretty simple in my code, but I'm still not knowledgeable enough to figure it out.
Here's my code:
Private Sub Command11_Click()
On Error Resume Next
Dim DateEntered As String
Dim App As String
Dim Issues As String
Dim Cause As String
Dim Resolution As String
Dim EnteredBy As String
Dim db As DAO.Database, rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.openrecordset("Select * from [tblEmail]"
DateEntered = Me![Date]
App = Me![Application]
Issues = Me![IssueFound]
Cause = Me![Cause]
Resolution = Me![Resolution]
EnteredBy = Me![EnteredBy]
'Create message
bodytext = bodytext & "Date: " & DateEntered & Chr$(10)
bodytext = bodytext & Chr$(10)
bodytext = bodytext & "Application: " & App & Chr$(10)
bodytext = bodytext & Chr$(10)
bodytext = bodytext & "Issue: " & Issues & Chr$(10)
bodytext = bodytext & Chr$(10)
bodytext = bodytext & "Cause: " & Cause & Chr$(10)
bodytext = bodytext & Chr$(10)
bodytext = bodytext & "Resolution: " & Resolution & Chr$(10)
bodytext = bodytext & Chr$(10)
bodytext = bodytext & "Entered By: " & EnteredBy
'E-mail above message
DoCmd.SendObject acSendNoObject, "", acFormatTXT, rst!emailAddress, , , "Knowledge Transfer", bodytext, True
End Sub
So, to recap, the email process works fine for what I want, except for populating the To: field. How can it get it to pull in all of the email address in the tblEmail table?
Any help is greatly appreciated!
Thanks much!
Elizabeth
After lots of trial and error I've figured out how to send email from my form. I have a knowledge database and want to have users click a button to send an email to a set group of people (list of email addresses - emailAddress - in a table - tblEmail). In the email, it will automatically populate the body of the email with the different fields on the knowledge form (issue, cause, resolution, etc). This I've figured out fine. The only thing that is not working for me is populating the To: field in the email. It will only put the first email in the table. I'm sure it's something pretty simple in my code, but I'm still not knowledgeable enough to figure it out.
Here's my code:
Private Sub Command11_Click()
On Error Resume Next
Dim DateEntered As String
Dim App As String
Dim Issues As String
Dim Cause As String
Dim Resolution As String
Dim EnteredBy As String
Dim db As DAO.Database, rst As DAO.Recordset
Set db = CurrentDb
Set rst = db.openrecordset("Select * from [tblEmail]"
DateEntered = Me![Date]
App = Me![Application]
Issues = Me![IssueFound]
Cause = Me![Cause]
Resolution = Me![Resolution]
EnteredBy = Me![EnteredBy]
'Create message
bodytext = bodytext & "Date: " & DateEntered & Chr$(10)
bodytext = bodytext & Chr$(10)
bodytext = bodytext & "Application: " & App & Chr$(10)
bodytext = bodytext & Chr$(10)
bodytext = bodytext & "Issue: " & Issues & Chr$(10)
bodytext = bodytext & Chr$(10)
bodytext = bodytext & "Cause: " & Cause & Chr$(10)
bodytext = bodytext & Chr$(10)
bodytext = bodytext & "Resolution: " & Resolution & Chr$(10)
bodytext = bodytext & Chr$(10)
bodytext = bodytext & "Entered By: " & EnteredBy
'E-mail above message
DoCmd.SendObject acSendNoObject, "", acFormatTXT, rst!emailAddress, , , "Knowledge Transfer", bodytext, True
End Sub
So, to recap, the email process works fine for what I want, except for populating the To: field. How can it get it to pull in all of the email address in the tblEmail table?
Any help is greatly appreciated!
Thanks much!
Elizabeth