Problem on sending e-mail

noliveira

New member
Local time
Today, 16:50
Joined
Sep 24, 2008
Messages
2
Dear all,
I´m having problem with this code... Can anyone help me?

The idea is send an e-mail for every mail fields on a table. But the code is reading always the same mail address:

Private Sub SendEMail()
On Error GoTo Err_SendEMail

Dim varTo As Variant
Dim stBody As String
Dim stSubject As String 'Subject line of e-mail
Dim errLoop As Error

'While tbl_mail_security_address.EOF
varTo = DLookup("[fldmailaddress]", "tbl_mail_security_address")

stSubject = "Information Security Information"
stBody = "Dear all," & Chr$(13) & Chr$(13) & _
"Please find attached file with the result of last
Information Security Audit task done." & Chr$(13) & _
"This is an automated message. Please do not respond
to this e-mail."

DoCmd.SendObject , , acFormatTXT, varTo, , , stSubject, stBody, -1
'Wend
Exit Sub

Err_Execute:
' Notify user of any errors that result from executing the query.
If DBEngine.Errors.Count > 0 Then
For Each errLoop In DBEngine.Errors
MsgBox "Error number: " & errLoop.Number & vbCr & errLoop.Description
Next errLoop
End If
Resume Next

Exit_SendEMail:
Exit Sub

Err_SendEMail:
MsgBox Err.Description
Resume Exit_SendEMail
End Sub

Thanks!
 

Users who are viewing this thread

Back
Top Bottom