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!

Access Report as Email Body 3

Status
Not open for further replies.

sunmorgus

Programmer
Nov 9, 2004
81
US
Hello all, I have a quick question. I use the code from faq705-1634 to send multiple report attachements via email, but I would like to know if it is possible to make one of these reports the body of the email. Can anyone help me figure this out? Thanks!
 
The linked FQA sets up the body of the messsage with this satement:

mobjNewMessage.Body = aBody

You have to set 'aBody' to the message text you want.

aBody = myreportname
 
Well, I tried that already, and all that does is put the name of my report in there as text.
 
Hi
Something like this? The idea is to save the report as HTML or RTF, then read it in:
Code:
Set fs = CreateObject("Scripting.FileSystemObject")
Set f = fs.OpenTextFile("C:\Report.rtf", ForReading)
RTFBody = f.readall
f.Close
'Then
aBody=RTFBody
You could also use:
Code:
Open "C:\Report.rtf" For Input As #1   
Do While Not EOF(1)
    Line Input #1, TextLine
    RTFBody = RTFBody & TextLine
Loop
Close #1
The above example is RTF, if you want to use a HTML report, you need change .Body to .HTMLBody.
 
Please insert into the first snippet of code above:
Const ForReading = 1, ForWriting = 2, ForAppending = 3
[sleeping]
 
Hopefully I won't sound too dumb by asking, but what do I declare fs and f as?
 
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


 

I think Remou would appreciate aknowledgement, too. He did the most of it if not all ..........
 
Sorry remou, that is what I get for paying attention. Excellent job by the way, exactly what I needed!
 
Is there any possible way to do this without having to save the file and go back and delete it? I'm looking for a solution to a similar problem but I don't want it saved on the clients computer.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top