Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Send Report In Body Of Email

Status
Not open for further replies.

kwor

MIS
Dec 10, 2008
35
AU
I have a parameter query to generate a report.
Up to four parameters may be passed from the form to the query.
Click a button on a form and the report works perfectly.
I also have another button to email the report via Outlook. This works perfectly as an attachment, however, I need to place the report in the body of the email.
I can do this by sending the report as text to a file and reading the file into the body of the email. This works but the formatting is text.
I would rather export the report as html and send that in the body of the email. This I can do with the code shown below.
However, if the report is more than one page, the html output is saved as more than one file. At the bottom of the email there is a line "First, Previous, Next , Last". This will not work for the email recipient.
If I could format the report not to paginate, everything would work.


Code:
' Output report to an html file in the system temp directory
strFileName = Environ("Temp") & "\report_temp.xml"
DoCmd.OutputTo acOutputReport, strReportName, acFormatHTML, strFileName, False
' Read html file in
Set oFilesys = CreateObject("Scripting.FileSystemObject")
Set oTxtStream = oFilesys.OpenTextFile(strFileName, 1)
txtHTML = oTxtStream.ReadAll
oTxtStream.Close
' Send information to Outlook
Set oTxtStream = Nothing
Set oFilesys = Nothing
Set olApp = New Outlook.Application
Set objMail = olApp.CreateItem(olMailItem)
With objMail
.BodyFormat = olFormatHTML
.HTMLBody = txtHTML
.Subject = strSubject
.Display
End With
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top