Solved

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

Posted on 2003-11-14
8
340 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
 
LVL 1

Author Comment

by:indyng
ID: 9749895
To mccredb

Is &vbcrlf a carriage return? Thanks
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now