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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sent report as body in email 1

Status
Not open for further replies.

onwagena

Technical User
Jan 11, 2004
8
NL
I have a report in Access and I want this report sent by email to several people. How can I compose an email with as body the report that I want to sent. I don't want to have the report as an attachment.
 
Hi
Something like this may do as a work around.
The idea is to save the report as HTML or RTF, then read it in:
Code:
Dim TextLine
Const ForReading = 1, ForWriting = 2, ForAppending = 3

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

Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("tblTable.rtf", ForReading)
RTFBody = f.ReadAll
f.Close
'==========================
'OR
'==========================
Open "tblTable.rtf" For Input As #1
Do While Not EOF(1)
    Line Input #1, TextLine
    RTFBody = RTFBody & TextLine
Loop
Close #1
'==========================
'Then email
'==========================
Set MyItem = MyApp.CreateItem(olMailItem)
With MyItem
   .To = "me@hotmail.com"
   .Subject = "SubjectLine"
   .Body = RTFBody
End With
MyItem.Display
End Sub

You can use HTML too, but you need .HTMLBody, rather than .Body

Regarding how to dim f, fs:
JerryKlmns (IS/IT--Management) 29 Aug 05 10:50
If you dont select the Microsoft Scripting Runtime

Dim fs As Object
Dim f As Object

Else

Dim fs As Scripting.FileSystemObject
Dim f As Object

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top