I have done tons of research on this and have actually made it work. Taking a report, exporting to html and the inserting it as the body of an email.
Here is the issue, once textbox out of all them is not updating correctly PARTIALLY. I have a group header that shows the total for the whole group. The group total is correct for the first 2, then the next 2 are copies of the 2nd group total! Makes no sense because i can manualy do this and i do not get the odd copy and paste.
Here are screenshots of what the report should show and what it does show in the email. I am aware the formatting does not get copied over to html and i can live with that.
(Its the shaded grey number - the 3rd and 4th down are copies of the 2nd down)
The code is:
Sub exporttohtml()
Dim strLine, strHTML As String
Dim OL As Outlook.Application
Dim MyItem As Outlook.MailItem
Set OL = New Outlook.Application
Set MyItem = Outlook.Application.CreateItem(olMailItem)
With MyItem
.To = "xxxxx@xxxx.com"
.Subject = "EOD and Access are completed for: " & Date
End With
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.OutputTo acOutputReport, "Daily Production Report", acFormatHTML, "P:\myreport.html"
Open "P:\myreport.html" For Input As 1
Do While Not EOF(1)
Input #1, strLine
strHTML = strHTML & strLine
Loop
Close 1
If Left(OL.Version, 2) = "50" Then
MyItem.BodyFormat = olFormatHTML
End If
MyItem.HTMLBody = strHTML
MyItem.Display
' MyItem.Send
End Sub