Can Access Report be in body of e-mail, not as an attachment?

G

Guest

I created a procedure that will e-mail the results of a report as an
attachment. Is there a way to have the report appear in the body of the
message so the recipient doesn't have to open an attachment to view it?
 
S

Steve

Yes but it loses all formatting. Depending on the report, it can become
impossible to read.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
S

Steve

Here is some code I have saved from somewhere that might be of some
help ----

There is a subform within an order form that holds what product were ordered
with the order number, quantity and price. The code below gets the
information from the subform to
apear with in the body of the email text.

'This first part sets up to allow you to read the details of the items
ordered
Dim CRS1 As ADODB.Recordset
Dim strSQL As String
Set CRS1 = New ADODB.Recordset
strSQL = "SELECT * FROM tblOrderDetails WHERE OrderID =" &
Forms!frmFormName!OrderID

'This part begins to build the body of the email
strBody = "Dear " & Forms!frmFormName!FirstName & ": " & vbCrLf &
vbCrLf
strBody = strBody & "Your order for the following items has been
receieved and has been shipped via "
strBody = strBody & Forms!frmFormName!ShipVia & " on " &
Forms!frmName!ShipDate & "."
strBody = strBody & vbCrLf & vbCrLf

'This part retrieves each item ordered and adds it to the body of the
email
CRS1.Open strSQL, CurrentProject.Connection, adOpenKeySet,
adLockReadOnly
While Not CRS1.EOF
strBody = strBody & CRS1.Fields("Qty") & " " &
CRS1.Fields("Item") & " @ " & CRS1.Fields("Price") & " Total: " & _
CRS1.Fields("Price") * CRS1.Fields("Qty") & vbCrLf
CRS1.MoveNext
Wend
CRS1.Close
Set CRS1 = Nothing

Note: The vbCrLf you will see in this code performs a Carriage Return
and Line Feed - like pressing Enter on your keyboard.

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
(e-mail address removed)
 
T

Tony Toews [MVP]

KimC said:
I created a procedure that will e-mail the results of a report as an
attachment. Is there a way to have the report appear in the body of the
message so the recipient doesn't have to open an attachment to view it?

To create a formatted document to send as an email you will need to
use VBA code to create a largish string. This string will then be
passed to the SendObject command or other method as the body of the
email. For more details including sample air code see my Tips page
on this topic at http://www.granite.ab.ca/access/email/formatted.htm.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 

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