froggiebeckie
Registered User.
- Local time
- Today, 08:55
- Joined
- Oct 11, 2002
- Messages
- 104
Hi, Y'all,
I've tried searching the site for help with this, but I'm still struggling with this email problem. Please take a look and see if you can spot what's wrong.
With code provided on here, the module will now run a query and generate an email based on the query results.
The TO:, SUBJECT:, and MESSAGE are all correct.
This is the code I'm using:
The problem is, I need to attach a form to this email. Each record returned in the query includes the path to the specific form needed.
I've tried adding:
Dim sAttach As String and
sAttach = .Fields(8) but
When I try to add sAttach, to the do command statement, it glitches out.
Any ideas on how to get this to attach the file specified in Field 8 of the query?
Once again,
I thank you for your patience and willingness to help.
BeckieO
I've tried searching the site for help with this, but I'm still struggling with this email problem. Please take a look and see if you can spot what's wrong.
With code provided on here, the module will now run a query and generate an email based on the query results.
The TO:, SUBJECT:, and MESSAGE are all correct.
This is the code I'm using:
Code:
Option Explicit
Public Sub SendFromQuery(Optional attachmentpath)
Dim MyDb As DAO.Database
Dim rsEmail As DAO.Recordset
Dim sToName As String
Dim sSubject As String
Dim sMessageBody As String
Set MyDb = CurrentDb()
Set rsEmail = MyDb.OpenRecordset("PMs Due Query", dbOpenSnapshot)
With rsEmail
.MoveFirst
Do Until rsEmail.EOF
If IsNull(.Fields(7)) = False Then
sToName = .Fields(7)
sSubject = "PMs Due : " & .Fields(1)
sMessageBody = .Fields(0) & " " & .Fields(1) & " Due Date " & .Fields(5)
DoCmd.SendObject acSendNoObject, , , _
sToName, , , sSubject, sMessageBody, False, False
End If
.MoveNext
Loop
End With
Set MyDb = Nothing
Set rsEmail = Nothing
End Sub
The problem is, I need to attach a form to this email. Each record returned in the query includes the path to the specific form needed.
I've tried adding:
Dim sAttach As String and
sAttach = .Fields(8) but
When I try to add sAttach, to the do command statement, it glitches out.
Any ideas on how to get this to attach the file specified in Field 8 of the query?
Once again,
I thank you for your patience and willingness to help.
BeckieO