Solved

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

Posted on 2003-11-14
8
330 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
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

708 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

12 Experts available now in Live!

Get 1:1 Help Now