VB Code to Email customers Order Details

S

Simon

I am trying to write some code that will email the customer
conformation of thier order, I have all the code apart from the part
that will list the products they have ordered as i am unsure how to
look up many items from a table

On the order form i have txtOrderNumber with related to
tblOrderProduct.OrderNumber

What i would like it to look like is the following

Product Name: LCD TV ( This would come from
tblOrderProduct.ProductName)
Product Code : 492750 ( This would come from
tblOrderProduct.ProductCode)
Quantity : 1 ( This would come from
tblOrderProduct.quantity)
Cost : £675.00 ( This would come from
tblOrderProduct.UnitCost)

Product Name: DVD Player
Product Code : 5837
Quantity : 1
Cost : £255.00

Product Name: LCD TV
Product Code : 492750
Quantity : 1
Cost : £675.00


If any one can point me in the right driection that would be great

Thanks
 
W

Wayne-I-M

Hi Simon

1st create the report you want to send
2nd create a form that has (somewhere) the 3 e mail address you want to send
it to (and the CC if you want)

Then use the send object method. If you should search on access help it
will give you a "run though". The code behind the OnClick event would look
something like this


DoCmd.SendObject acReport, "REPORTNAME", "RichTextFormat(*.rtf)",
Forms!FORMNAME!EMAIL ADDRESS, Forms!FORMNAME!EMAILADDRESS-CC, "", "EMAIL
SUBJECT", "EMAIL CONTENT", False, ""


Notes
"RichTextFormat(*.rtf)" - this would format the report as RTF for Word Doc
but there are other formats such as excel, etc


Forms!FORMNAME!EMAIL ADDRESS - this is the main e mail address the report
will be sent to


Forms!FOEMNAME!EMAILADDRESS-CC - this is used if you want to send a copy of
the report to other address at the same time


"EMAIL SUBJECT" - Insert text between the quotes that you want to apprear in
the Subject line of the email


EMAIL CONTENT" - insert text here that you want to apprear at the top of
the main body of the e mail.


Hope this helps
 
S

Simon

Hi Simon

1st create the report you want to send
2nd create a form that has (somewhere) the 3 e mail address you want to send
it to (and the CC if you want)

Then use the send object method.  If you should search on access help it
will give you a "run though".  The code behind the OnClick event would look
something like this

DoCmd.SendObject acReport, "REPORTNAME", "RichTextFormat(*.rtf)",
Forms!FORMNAME!EMAIL ADDRESS, Forms!FORMNAME!EMAILADDRESS-CC, "", "EMAIL
SUBJECT", "EMAIL CONTENT", False, ""

Notes
"RichTextFormat(*.rtf)"  -  this would format the report as RTF for Word Doc
but there are other formats such as excel, etc

Forms!FORMNAME!EMAIL ADDRESS -  this is the main e mail address the report
will be sent to

Forms!FOEMNAME!EMAILADDRESS-CC - this is used if you want to send a copy of
the report to other address at the same time

"EMAIL SUBJECT" - Insert text between the quotes that you want to apprearin
the Subject line of the email

EMAIL CONTENT" - insert text here that you want to apprear  at the top of
the main body of the e mail.

Hope this helps

--
Wayne
Manchester, England.












- Show quoted text -

Thanks very much but i do not really want an attachent i would like
all text in an email
 
W

Wayne-I-M

No problems

If you are working on a form with the details you want to e mail you just
need to add these contents (of the controls) to the body of your e mail.

This sort of thing "Hi " & [ContactName] & Chr(13) + Chr(10) & Chr(13) +
Chr(10) & "I have sent you this information" & Chr(13) + Chr(10)
&[SomeStuffHere]

Use send No object

If not - can you give more details of what you are trying to do ?

Are you trying to send a format outlook mail ?
 
S

Simon

No problems

If you are working on a form with the details you want to e mail you just
need to add these contents (of the controls) to the body of your e mail.

This sort of thing "Hi " & [ContactName] & Chr(13) + Chr(10) & Chr(13) +
Chr(10) & "I have sent you this information" & Chr(13) + Chr(10)
&[SomeStuffHere]

Use send No object

If not - can you give more details of what you are trying to do ?

Are you trying to send a format outlook mail ?

--
Wayne
Manchester, England.



Thanks very much but i do not really want an attachent i would like
all text in an email- Hide quoted text -

- Show quoted text -

I have a Database that i use for my online shop, A customer places an
order, i enter details into tblCustomer, tblOrder and
tblOrderProducts.

Once the order is entered i want to send the customer am email saying
thank you for your order ect, and to list in the email the products
the customer has bought.

So far i have coded it to creat the email address, put customers name,
email and the most of the body of the email, the only think i have no
idea how to do is list the products the customer has bought as this
would need to be a recuring list as customer could have many products.

what would the code be to look up in tblOrderProduct where order
number is me.OrderNumber and then desplay all product bought along
with quantity bought

Product Name: LCD TV ( This would come from
tblOrderProduct.ProductName)
Product Code : 492750 ( This would come from
tblOrderProduct.ProductCode)
Quantity : 1 ( This would come from
tblOrderProduct.UnitCost)

Ect Ect with all products customer bought
 
W

Wayne-I-M

There are a few method you can use - none of them as good as send your report
as an attachment - this is what people expect - you can use it as a reciept
as well as an order confirmation.

1 method
output the text report to text (docmd outputto) then assign this as a string
vairable

2 method
output your report to html and include this in the body of the e mail
se
http://msdn.microsoft.com/en-us/lib...odc_ac_olauto_sendanoutlookmessageusingaccess
for details of this

there are some other methods - but again, I would send a report as an
attachment - but up to you
--
Wayne
Manchester, England.



Simon said:
No problems

If you are working on a form with the details you want to e mail you just
need to add these contents (of the controls) to the body of your e mail.

This sort of thing "Hi " & [ContactName] & Chr(13) + Chr(10) & Chr(13) +
Chr(10) & "I have sent you this information" & Chr(13) + Chr(10)
&[SomeStuffHere]

Use send No object

If not - can you give more details of what you are trying to do ?

Are you trying to send a format outlook mail ?

--
Wayne
Manchester, England.



Simon said:
On Oct 19, 12:58 pm, Wayne-I-M <[email protected]>
wrote:
Hi Simon
1st create the report you want to send
2nd create a form that has (somewhere) the 3 e mail address you want to send
it to (and the CC if you want)
Then use the send object method. If you should search on access help it
will give you a "run though". The code behind the OnClick event would look
something like this
DoCmd.SendObject acReport, "REPORTNAME", "RichTextFormat(*.rtf)",
Forms!FORMNAME!EMAIL ADDRESS, Forms!FORMNAME!EMAILADDRESS-CC, "", "EMAIL
SUBJECT", "EMAIL CONTENT", False, ""
Notes
"RichTextFormat(*.rtf)" - this would format the report as RTF for Word Doc
but there are other formats such as excel, etc
Forms!FORMNAME!EMAIL ADDRESS - this is the main e mail address the report
will be sent to
Forms!FOEMNAME!EMAILADDRESS-CC - this is used if you want to send a copy of
the report to other address at the same time
"EMAIL SUBJECT" - Insert text between the quotes that you want to apprear in
the Subject line of the email
EMAIL CONTENT" - insert text here that you want to apprear at the top of
the main body of the e mail.
Hope this helps
:
I am trying to write some code that will email the customer
conformation of thier order, I have all the code apart from the part
that will list the products they have ordered as i am unsure how to
look up many items from a table
On the order form i have txtOrderNumber with related to
tblOrderProduct.OrderNumber
What i would like it to look like is the following
Product Name: LCD TV ( This would come from
tblOrderProduct.ProductName)
Product Code : 492750 ( This would come from
tblOrderProduct.ProductCode)
Quantity : 1 ( This would come from
tblOrderProduct.quantity)
Cost : £675.00 ( This would come from
tblOrderProduct.UnitCost)
Product Name: DVD Player
Product Code : 5837
Quantity : 1
Cost : £255.00
Product Name: LCD TV
Product Code : 492750
Quantity : 1
Cost : £675.00
If any one can point me in the right driection that would be great
Thanks- Hide quoted text -
- Show quoted text -
Thanks very much but i do not really want an attachent i would like
all text in an email- Hide quoted text -

- Show quoted text -

I have a Database that i use for my online shop, A customer places an
order, i enter details into tblCustomer, tblOrder and
tblOrderProducts.

Once the order is entered i want to send the customer am email saying
thank you for your order ect, and to list in the email the products
the customer has bought.

So far i have coded it to creat the email address, put customers name,
email and the most of the body of the email, the only think i have no
idea how to do is list the products the customer has bought as this
would need to be a recuring list as customer could have many products.

what would the code be to look up in tblOrderProduct where order
number is me.OrderNumber and then desplay all product bought along
with quantity bought

Product Name: LCD TV ( This would come from
tblOrderProduct.ProductName)
Product Code : 492750 ( This would come from
tblOrderProduct.ProductCode)
Quantity : 1 ( This would come from
tblOrderProduct.UnitCost)

Ect Ect with all products customer bought
 
J

Juventino trevizo

I am trying to write some code that will email the customer
conformation of thier order, I have all the code apart from the part
that will list the products they have ordered as i am unsure how to
look up many items from a table

On the order form i have txtOrderNumber with related to
tblOrderProduct.OrderNumber

What i would like it to look like is the following

Product Name: LCD TV ( This would come from
tblOrderProduct.ProductName)
Product Code : 492750 ( This would come from
tblOrderProduct.ProductCode)
Quantity : 1 ( This would come from
tblOrderProduct.quantity)
Cost : £675.00 ( This would come from
tblOrderProduct.UnitCost)

Product Name: DVD Player
Product Code : 5837
Quantity : 1
Cost : £255.00

Product Name: LCD TV
Product Code : 492750
Quantity : 1
Cost : £675.00


If any one can point me in the right driection that would be great

Thanks
 

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