Hi all,
Having spent the last hour Googling sites for answers to the issue I'm having, I haven't been able to find a solution so apologies for creating another thread about this (it seems this is quite a popular problem people are having!).
So basically, I want to email a report I'm generating in Access to someone but putting the report into the body of the email, not sending it as an attachment. After looking through these forums, I found the following thread which was really useful on getting the basics done:
https://www.accessforums.net/program...ody-10101.html
This is the code I've skilfully copied and pasted into my Access db:
So the above code correctly creates an email and populates the "To" and "Subject" fields fine. However, when it goes to populate the body of the email, this is what I get:Code:Function sendRTFEmail() Const ForReading = 1, ForWriting = 2, ForAppending = 3 Dim fs, f Dim objOL As Outlook.Application Dim MyItem As Outlook.MailItem Set objOL = New Outlook.Application Set MyItem = Outlook.Application.CreateItem(olMailItem) DoCmd.OutputTo acOutputReport, "SignOff", acFormatRTF, "C:\Users\john_smith\Desktop\ExampleRTFReport.rtf" Set fs = CreateObject("Scripting.FileSystemObject") Set f = fs.OpenTextFile("C:\Users\john_smith\Desktop\ExampleRTFReport.rtf", ForReading) RTFBody = f.readall f.Close With MyItem .To = "john.smith@example.com" .Subject = "Sign Off email" .body = RTFBody End With MyItem.display End Function
http://i47.tinypic.com/2wcenb5.jpg
It's not replicating the layout of the report in the body of the email. It just seems to be giving me a load of rubbish instead!
I've also tried changing the ".body" to ".HTMLBody" but that doesn't seem to help.
Does anyone have any idea where I'm going wrong?
Thanks!