Send Report in Body of Outlook (1 Viewer)

Ksabai

Registered User.
Local time
Today, 08:05
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
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:05
Joined
Oct 29, 2018
Messages
21,358
Does your report include images? If so, it would be a little harder.
 

Ksabai

Registered User.
Local time
Today, 08:05
Joined
Jul 31, 2017
Messages
104
No, They are more like excel sheet reports with Color and Grids as borders
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:05
Joined
Oct 29, 2018
Messages
21,358
I see. Then, you should be able to use the <table> tag in your HTMLBody to present the report in your email.
 

June7

AWF VIP
Local time
Today, 07:05
Joined
Mar 9, 2014
Messages
5,423
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:

theDBguy

I’m here to help
Staff member
Local time
Today, 08:05
Joined
Oct 29, 2018
Messages
21,358
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...
 

June7

AWF VIP
Local time
Today, 07:05
Joined
Mar 9, 2014
Messages
5,423
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:

Wayne

Crazy Canuck
Local time
Today, 11:05
Joined
Nov 4, 2012
Messages
176
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
 

June7

AWF VIP
Local time
Today, 07:05
Joined
Mar 9, 2014
Messages
5,423
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

Top Bottom