Send Email from access

S

Simon

I have writen some code to send to a customer confirming there order.
But i am unsure how to included a list of products they have ordered
as i do not know how to code it to display a list from looking up data
in tblOrderProducts and display ProductName based on the
CustomerOrderNumber

Any help on this would be great

Thanks
 
A

Arvin Meyer [MVP]

Build a recordset and output it to your message body. The code to send an
email in out look is here:

http://www.datastrat.com/Code/OutlookEmail.txt

So using that code, you'd build the recordset like:

Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim srtSQL As String
Dim strMsg As String

Set db = CurrentDb
strSQL= "Select ProductName From tblOrderProducts Where CustomerOrderNumber
=" & Me.txtCustomerOrderNumber

Set rst = db.OpenRescordset(strSQL)

With rst
.MoveFirst
Do Until .EOF
strMsg = !ProductName & vbCrLf
.MoveNext
Loop
End With

Now in the the Outlook code, replace the line:

..body = "The body doesn't matter, just the attachment"

with

..body = strMsg

And finish the Outlook code. Make sure you close your recordset and set it
and the db reference to Nothing.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top