Send group email

G

Guest

I have a form set up to generate group emails based on the user's inputs. It
works as intended, except that when the number of email addresses gets over
10 or so, it does not. In that case, it generates an email with only the
very first email address, and that is cut off at the "@" symbol (so if the
first email address was "(e-mail address removed)" it would generate an email addressed
to "john"). Here is the code that I am using:

Private Sub btnEmailState_Click()
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strEmail As String

Set db = CurrentDb()
Set qdf = db.QueryDefs("qryEmailState")
qdf.Parameters!status1 = Forms("Email Volunteers").Controls("txtActive")
qdf.Parameters!status2 = Forms("Email Volunteers").Controls("txtInactive")
qdf.Parameters!status3 = Forms("Email
Volunteers").Controls("txtProspective")
qdf.Parameters!status4 = Forms("Email Volunteers").Controls("txtClosed")
qdf.Parameters![LeaveDate] = Forms("Email
Volunteers").Controls("txtEmailLeave")
Set rst = qdf.OpenRecordset

With rst
If (Not .BOF) And (Not .EOF) Then
.MoveFirst
strEmail = .Fields("email")
.MoveNext
End If

If (Not .BOF) And (Not .EOF) Then
Do Until .EOF
strEmail = strEmail & ", " & .Fields("email")
.MoveNext
Loop
End If
.Close
End With

If strEmail = "" Then
MsgBox "No email addresses were found for the State"
Exit Sub
Else
DoCmd.SendObject acSendNoObject, , acFormatTXT, strEmail, , , , , True
End If

End Sub

Also, my email program is Lotus Notes, if that makes any difference. Also,
I tried having it export the string "strEmail" to a text box and then
generating the email from that, but with the same results. If I manually
copy and paste from that text box, it does work, however. Very confusing (to
me, at least. Hopefully not to everyone here!)
 
G

Guest

Thanks for the idea, but I'm afraid it produces the same results

UpRider said:
Maybe try a semicolon instead of a comma between email addresses?
UpRider

tminn said:
I have a form set up to generate group emails based on the user's inputs.
It
works as intended, except that when the number of email addresses gets
over
10 or so, it does not. In that case, it generates an email with only the
very first email address, and that is cut off at the "@" symbol (so if the
first email address was "(e-mail address removed)" it would generate an email
addressed
to "john"). Here is the code that I am using:

Private Sub btnEmailState_Click()
Dim rst As DAO.Recordset
Dim db As DAO.Database
Dim qdf As DAO.QueryDef
Dim strEmail As String

Set db = CurrentDb()
Set qdf = db.QueryDefs("qryEmailState")
qdf.Parameters!status1 = Forms("Email
Volunteers").Controls("txtActive")
qdf.Parameters!status2 = Forms("Email
Volunteers").Controls("txtInactive")
qdf.Parameters!status3 = Forms("Email
Volunteers").Controls("txtProspective")
qdf.Parameters!status4 = Forms("Email
Volunteers").Controls("txtClosed")
qdf.Parameters![LeaveDate] = Forms("Email
Volunteers").Controls("txtEmailLeave")
Set rst = qdf.OpenRecordset

With rst
If (Not .BOF) And (Not .EOF) Then
.MoveFirst
strEmail = .Fields("email")
.MoveNext
End If

If (Not .BOF) And (Not .EOF) Then
Do Until .EOF
strEmail = strEmail & ", " & .Fields("email")
.MoveNext
Loop
End If
.Close
End With

If strEmail = "" Then
MsgBox "No email addresses were found for the State"
Exit Sub
Else
DoCmd.SendObject acSendNoObject, , acFormatTXT, strEmail, , , , ,
True
End If

End Sub

Also, my email program is Lotus Notes, if that makes any difference.
Also,
I tried having it export the string "strEmail" to a text box and then
generating the email from that, but with the same results. If I manually
copy and paste from that text box, it does work, however. Very confusing
(to
me, at least. Hopefully not to everyone here!)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top