S.*******@shos.co.uk wrote:
Hi
I hope some one can help, as i am not very good on Access
I have built a database for placing orders for customers, On the Order
Form i would like a button that would send out a email to say that the
order has been placed, then another button that order has been
despatched.
I have looked on the internet for code and found sum but do not
understand it.
As the order form only has Customer Number im not sure how to code it
to look up customers email address from tblCustomers
If any one could help i would be very greatful i am able to send the
database to you if u want to have a look but i can warn you it not
great.
Thanks
Simon
If you aren't needing to send any other attachments from other
applications then Docmd.SendObject is what you want.
Dim strTo As String
Dim strBody As String
Dim strSubject As String
strTo = Dlookup("EmailAddressFieldName","CustomerTableName ",_
"CustomerID = " & Me.CustomerID)
strBody = "Hello. How Are You?"
strSubject = "Test Subject"
DoCmd.SendObject acSendReport, "YourReport", acFormatTXT, _
strTo, , , strSubect, strBody, True
The above sends an email to whoever strTo is equal to. It sends a
report called YourReport. You would most likely want to send the report
that is filtered to the customer you are sending it to.
DoCmd.SendObject , , acFormatTXT, _
strTo, , , strSubect, strBody, True
will simply send an email to somebody with just subject and body, no
attachment of report or query.
Hopefully this can get you started.