Solved

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

Posted on 2003-11-14
8
368 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
10 Questions to Ask when Buying Backup Software

Choosing the right backup solution for your organization can be a daunting task. To make the selection process easier, ask solution providers these 10 key questions.

 
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

617 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