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

Access SendObject outlook email?

Status
Not open for further replies.

nmapeso

Technical User
Aug 26, 2005
28
US
Is there a way for my report on rich text format as part of the body/message instead of a MSword attachment. Send email works okay but just don't want may report as attachment.
 
The reason of sending report as part of the message as report only consist on one page. Instead of opening the MSword attachment when recieved by recipient.
 
Hi
Something like this? The idea is to save the report as HTML or RTF, then read it in:

Code:
Sub RTFBody()
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("C:\Report.rtf", ForReading)
RTFBody = f.readall
f.Close

Set MyItem = MyApp.CreateItem(olMailItem)
With MyItem
   .To = "me@hotmail.com"
   .Subject = "txtSubjectLine"
   .Body = RTFBody
End With
MyItem.Display
End Sub
 
You can 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
Instead of FileSystemObject
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top