Solved

How can data be read into the message body of an email from a form and sent?

Posted on 2003-11-14
8
361 Views
Last Modified: 2006-11-17
Hi Experts

This is a repeat of a question I had asked earlier. I'm still uncertain how to do this. I have increased the points.

I created an Access database to invoice deliveries. I want to be able to send the delivery details contained in a form via email. I want the data to be read into the message body of the email. I don't want to send the form as an attachment. Is this possible? What is the VBA code to perform this task?

The message body of the email must look like the following example:

C1 seafood $10
C2 steak     $12
Subtotal =  $22
Taxes = $2
Total = $24

Currently a report with data read from a form is sent as an attachment automatically on a click of a button. I want the data to be sent in the message body of the email so I can apply a rules wizrd to print the email automatically upon arrival at the destination location. This is the reason why I require the data be in the message body of the text.

Thanks in advance.
0
Comment
Question by:indyng
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 23

Expert Comment

by:heer2351
ID: 9747351
Have a look at this link:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnacc97/html/emldata.asp

it explains how to do what you want.

More email tips can be found here:
http://www.granite.ab.ca/access/email.htm
0
 
LVL 3

Accepted Solution

by:
mccredb earned 500 total points
ID: 9747367
indyng

Your question is similar to the one posted by Tammi_UK

http://www.experts-exchange.com/Databases/MS_Access/Q_20788626.html

Take a look, it might give you the ideas you need.

Regards,
David
0
 
LVL 3

Expert Comment

by:Ramfublio
ID: 9747681
Here is some sample code (assumes you have a reference to the Outlook library):

Sub CreateEmail()

Dim outlApp As New Outlook.Application
Dim outlEmail As Outlook.MailItem

Set outlEmail = outlApp.CreateItem(olMailItem)

With outlEmail
    .To = "To Address"
    .Body = "C1 seafood $10" & vbNewLine & _
                "C2 steak     $12" & vbNewLine & _
                "Subtotal =  $22" & vbNewLine & _
                "Taxes = $2" & vbNewLine & _
                "Total = $24"
    .Subject = "Your Subject"
    .Display
End With

Set outlApp = Nothing
Set outlEmail = Nothing

End Sub
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 1

Author Comment

by:indyng
ID: 9749895
To mccredb

Is &vbcrlf a carriage return? Thanks
0
 
LVL 23

Expert Comment

by:heer2351
ID: 9750242
vbcrlf is a carriage return (cr) linefeed (lf) and this is equal to vbNewLine or chr(13) & chr(10)
0
 
LVL 1

Author Comment

by:indyng
ID: 9751773
Thanks!!
0
 
LVL 1

Author Comment

by:indyng
ID: 9752192
How do I put in a space between data that is read? Thanks
0
 
LVL 3

Expert Comment

by:mccredb
ID: 9762470
Thanks indyng for the points

to add a space use:  

[first field]  & " " & [second field]

Thanks heer2351 for explaining the vbcrlf constant.    
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question