I am trying to get Access to add email addresses from a table to an Outlook distro list. Some of my users are very computer illiterate, and I find it easiest to have them update the table through a form I have built. My current VBA will send to a specific set of addresses. I don't know enough about VBA to figure out how to tell it what to do, and haven't had any luck finding the code through google.
My current code is:
Public Sub eMailDistro_Click()
Dim subject As String
Dim body As String
Dim EmailAddress As String
Dim rs As Object
Dim strSQL As String
Dim count As Integer
Dim recount As Integer
'set up sql string that opens query for selected group
strSQL = ("SELECT [strRecipientEmail] FROM [tblEmailTemp];")
'set recordset to sql string to open qry
Set rs = CurrentDb.OpenRecordset(strSQL, dbOpenDynaset)
' move to last record to ensure record count is correct
rs.MoveLast
'move back to first record
rs.MoveFirst
'set variable recount to number of records
recount = rs.RecordCount
'start for next loop
For count = 1 To recount
'MsgBox rs![strEmailAddress]
EmailAddress = EmailAddress & rs![strRecipientEmail] & ";"
'move to next recordset
rs.MoveNext
'increment the for/next counter
Next count
'remove the spare ";" from end of last email address
EmailAddress = Left(EmailAddress, (Len(EmailAddress) - 1))
'MsgBox recount & "" & Email Address
'close the recordset
rs.Close
'set it to nothing
Set rs = Nothing
'put info in subject line
subject = "Funeral Honors Request for:"
'put info in body
body = "Please contact the funeral home, verify details & email us back when done. Send your response to ***EMAIL ADDRESS REMOVED***
'send the email
DoCmd.SendObject , , , EmailAddress, , , subject, body, True
EmailAddress = ""
'end
End Sub
My apologies if my explinations are confusing, I'm in the process of trying to teach myself VBA.