views:

9

answers:

1

I dont know VBA. Is there a way for me have the macro to send the email where the report would be in the body of the email and not as an attachment? I currently use the "send-object" command and send it in html format , Please advse. thank you very much

A: 

If you are using Outlook, you can write a report or query to disk and use either HTMLBody or RTFBody, it is a while since I tested this, I hope it is still useful.

Const ForReading = 1, ForWriting = 2, ForAppending = 3

Dim fs, f
Dim RTFBody
Dim MyApp As New Outlook.Application
Dim MyItem As Outlook.MailItem

DoCmd.OutputTo acOutputReport, "Report1", acFormatRTF, "Report1.rtf"
''DoCmd.OutputTo acOutputQuery, "Query1", acFormatHTML, "Query1.htm"

Set fs = CreateObject("Scripting.FileSystemObject")

Set f = fs.OpenTextFile("Report1.rtf", ForReading)
''Set f = fs.OpenTextFile("Query1.htm", ForReading)
RTFBody = f.ReadAll
''Debug.Print RTFBody
f.Close

Set MyItem = MyApp.CreateItem(olMailItem)
With MyItem
   .To = "[email protected]"
   .Subject = "Subject"
   .RTFBody = RTFBody
   ''.HTMLBody = RTFBody
End With
MyItem.Display
Remou