Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Make Access Report as Body of Email

Status
Not open for further replies.

joshryanhr

Technical User
Sep 6, 2009
13
US
How do you make a report be the body of an email. I am using the following code to send it as an attachment, but I need it to be the body instead. Also I need the to and cc to generate from a field i have on a form.

Private Sub Command129_Click()

DoCmd.SendObject acSendReport, "Query for disputes report", acFormatSNP, Me.emailto, Me.email2, , "Dispute Update", Open Attatchment to view update.", True



End Sub
 
Thinks I put the following code in and now it works. Also as a bonus if you cancle the email i dont get the error that says you have cancled and lock access up any more.

Private Sub Command129_Click()

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

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

'DoCmd.OutputTo acOutputReport, "Report1", acFormatRTF, "Report1.rtf"
DoCmd.OutputTo acOutputReport, "Disputesupdate", acFormatHTML, "Disputesupdate.htm"
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("Disputesupdate.htm", ForReading)
'Set f = fs.OpenTextFile("Report1.rtf", ForReading)
RTFBody = f.ReadAll
f.Close

Set MyItem = MyApp.CreateItem(olMailItem)
With MyItem
.To = Me.emailto
.CC = Me.email2
.Subject = "Dispute Update"
.HTMLBody = RTFBody
End With
MyItem.Display



End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top