Email VBA Help

dan231

Registered User.
Local time
Today, 03:30
Joined
Jan 8, 2008
Messages
158
I'm using the code below and am getting a runtime error 3061 "Too few perameters. Expected 1." Error.

I am basing my code on this post.

I am pulling my email addresses from a query that is filtered from a combobox.

Code:
Private Sub Command2_Click()

Dim rsEmail As DAO.Recordset
Dim strEmail As String
Set rsEmail = CurrentDb.OpenRecordset("EmailAdds")

Do While Not rsEmail.EOF
strEmail = rsEmail.Fields("EmailAddress").Value & ";"

rsEmail.MoveNext

Loop
strEmail = Left$(strEmail, Len(strEmail) - 1)
DoCmd.SendObject , , , , , strEmail, _
"Subject", _
"Good Afternoon" & _
vbCrLf & vbCrLf & "Your Message.", False

Set rsEmail = Nothing

MsgBox "Emails have been sent"
End Sub

I debug and it highlights:
Set rsEmail = CurrentDb.OpenRecordset("EmailAdds") --> EmailAdds is my qry name.

Should I not be using the OpenRecordset? If not, what should I be using? I know I'm close...
 
Not sure about this but is the query updateable? I've used similar lines in the past with queries exactly as you have them with no problems. Never tried it with a query that's not updateable. Maybe you need an "rsEmail.MoveFirst" in there after you set rsEmail? But if you're having trouble setting rsEmail I would guess that either the query is not updateable or it doesn't exist. The link below may help:

http://support.microsoft.com/kb/105522

Seems there may be a problem with the query.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom