Send Report in Body of Outlook

Ksabai

Registered User.
Local time
Today, 09:45
Joined
Jul 31, 2017
Messages
104
Dear All,

The Following is the Code iam using to send the File as attachment thru outlook, i require some reports to be sent thru body of the email in outlook. Can anyone help

Dim sFile As String
Dim sFolder As String
Dim sSubject As String
Dim sMessage As String

sFolder = Application.CurrentProject.Path & "\Reports"
sFile = Application.CurrentProject.Path & "\Reports" & "Report.html"
If FolderExist(sFolder) = False Then MkDir (sFolder)
DoCmd.OutputTo acOutputReport, "rptShipDue", acFormatHTML, sFile, False

sSubject = "Report "
sMessage = "<HTML><BODY> " & "Dear Sirs" & "<Br> <Br> Please find below the Report." & "<Br> <Br> Kindly advice of any Discrepancies." & "<Br> <Br> Regards," & "</body></html>"

Call SendHTMLMail(" ", sSubject, sMessage, True, , Array(sFile))

Awaiting your help
 
Does your report include images? If so, it would be a little harder.
 
No, They are more like excel sheet reports with Color and Grids as borders
 
I see. Then, you should be able to use the <table> tag in your HTMLBody to present the report in your email.
 
Do you want to send multiple records or just current record of form? Options:

1. reference controls of form or loop through recordset to build string, if you want in a table, have to use HTML tags

2. export to PDF and convert to JPG or PNG or BMP, embed in HTMLBody with HTML tags, although not sure how this handles multi-page image
 
Last edited:
2. export to XML file and insert the XML file into HTMLBody
This is an interesting option. Would it come out as a table grid in the email? Just curious...
 
Correction. My memory was faulty. I was trying to recall something I read a while ago.

Found the info again and it involves embedding Outlook signature htm file in email body to include a signature block. I now remember trying it and wasn't able to get it to work.

So only 2 options? Edited post to change.

However, quote from another forum thread:
The problem is that anything in the body of the E-mail message needs to be in a format that is supported by the message body. If you are using HTML-format messages (which is now the default for most E-mail applications, including Microsoft Outlook), that means you really need to convert the report to HTML - which is not one of the formats Access 2010 provides.

You could probably export the report as a Rich Text Format (.RTF) file, open that file in Microsoft Word, and either save it as an HTML file or (if you are using Outlook as your E-mail application) copy the contents of the word document to the clipboard and paste it into the message (by using Office Automation in your VBA procedure, you can do all of this from within Access). However, it has been my experience that the translation through RTF does not preserve the layout of complicated documents such as Access reports. I personally think you will be better off sending the PDF file as an attachment.
 
Last edited:
How do you get this to work if the records you want to display in the HTML table in the body of the email are coming from a different table or sub form? I've been playing with it for a couple of days now, but can't seem to get it to work. Any advice would be appreciated.

Wayne
 
Open a recordset object and loop through records. I referenced a link demonstrating that.

Recordset can be opened with a SELECT query statement that pulls from whatever tables you want.

Should start your own thread with attempted code if you need more help.
 

Users who are viewing this thread

Back
Top Bottom