A
APH
Hi Evryone
I am trying to set up so that I can send emails straight from Access. Using
W2k and Access 2000 on this machine.
My code is as follows:
Public Sub Email()
Dim db As Database
Dim emailrecs As Recordset
Dim objOutlook As New Outlook.Application
Dim objMessage As MailItem
Dim strMessage As String
Dim strSQL As String
Set db = CurrentDb()
Set emailrecs = db.OpenRecordset("qryFollowUp")
While Not emailrecs.EOF
strMessage = "Dear " & emailrecs("Title") & " " & ("Surname") & _
vbCrLf & vbCrFl & _
"test text test text"
If Not IsNull(emailrecs("tblContacts.email")) Then
With objMessage
.to = (e-mail address removed)
.Subject = "test message test message"
.body = strMessage
.send
End With
End If
emailrecs.MoveNext
Wend
emailrecs.Close
Set emailrecs = Nothing
Set objOutlook = Nothing
Set objMessage = Nothing
End Sub
I amgetting an error message at the line:
Set emailrecs = db.OpenRecordset("qryFollowUp") -telling me that I have
error 3061, Too few parameters, Exprected 1.
Can someone tell me what that means, apart from the fact that I have it
wrong!
Thanks
Alex
I am trying to set up so that I can send emails straight from Access. Using
W2k and Access 2000 on this machine.
My code is as follows:
Public Sub Email()
Dim db As Database
Dim emailrecs As Recordset
Dim objOutlook As New Outlook.Application
Dim objMessage As MailItem
Dim strMessage As String
Dim strSQL As String
Set db = CurrentDb()
Set emailrecs = db.OpenRecordset("qryFollowUp")
While Not emailrecs.EOF
strMessage = "Dear " & emailrecs("Title") & " " & ("Surname") & _
vbCrLf & vbCrFl & _
"test text test text"
If Not IsNull(emailrecs("tblContacts.email")) Then
With objMessage
.to = (e-mail address removed)
.Subject = "test message test message"
.body = strMessage
.send
End With
End If
emailrecs.MoveNext
Wend
emailrecs.Close
Set emailrecs = Nothing
Set objOutlook = Nothing
Set objMessage = Nothing
End Sub
I amgetting an error message at the line:
Set emailrecs = db.OpenRecordset("qryFollowUp") -telling me that I have
error 3061, Too few parameters, Exprected 1.
Can someone tell me what that means, apart from the fact that I have it
wrong!
Thanks
Alex