Referencing fields

J

Jessie

Hello,

I am trying to automate a confirmation email from a form command button. I
need to loop through the records and specify the recipient of the email from
a field. I also need to add information from other fields in the body of the
email.

Here is what I have so far. The code works and sends the email out, but i
can't get the information from the fields to populate the email or recipient
value. And I am not sure how to get it to recognizes the table fields.

Dim db As Database
Dim rs As DAO.Recordset

Set db = CurrentDb
Set rs = db.OpenRecordset("test")

Do While Not rs.EOF
Dim objOutlook As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Outlook.Recipient
Dim objOutlookAttach As Outlook.Attachment


Set objOutlook = CreateObject("Outlook.Application")


Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

With objOutlookMsg

Set objOutlookRecip = .Recipients.Add(<TEST.EmailField>)
objOutlookRecip.Type = olTo




.Subject = "Summer Picnic Confirmation"
.Body = "We show that you have " & test.NoGuests & " people in
your party"
.Importance = olImportanceHigh


For Each objOutlookRecip In .Recipients
objOutlookRecip.Resolve
Next


If DisplayMsg Then
.Display
Else
.Save
.Send
End If
End With
Set objOutlook = Nothing
rs.MoveNext
Loop
End Sub
 
Top