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

HTMLBody Problem...

Status
Not open for further replies.

Rjc8513

Technical User
Feb 12, 2001
140
0
0
US
I'm stumped. I have nine separate html files which I paste into the body of an e-mail message in Outlook. File No. 1 is pasted first, then a carriage return, then I type a line of "=" across the page, then paste File No. 2 below. I continue until all nine files have been pasted.

I am trying to automate this process but cannot get it just right. Below is my code so far:


Function eMail_Test()

Dim dbs As DAO.Database
Dim MailList As DAO.Recordset
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim SubjectLine As String
Dim MsgBodyFile1 As String
Dim MsgBodyFile2 As String
Dim fso As FileSystemObject
Dim MsgBody1 As TextStream
Dim MsgBody2 As TextStream
Dim MsgBodyText As String
Dim MsgBodyText1 As String
Dim MsgBodyText2 As String

Set dbs = CurrentDb()
Set fso = New FileSystemObject

SubjectLine$ = InputBox$("Enter the e-mail subject line...", _
"ENTER E-MAIL SUBJECT LINE", "Week-to-date Overtime by Function Report: Week nn, through ddd...")
MsgBodyFile1$ = "C:\temp\OT Wktd by Plant.htm"
MsgBodyFile2$ = "C:\temp\OT Wktd by MPOO.htm"

Set MsgBody1 = fso_OpenTextFile(MsgBodyFile1, ForReading, False, TristateUseDefault)
MsgBodyText1 = MsgBody1.ReadAll
MsgBody1.Close

Set MsgBody2 = fso_OpenTextFile(MsgBodyFile2, ForReading, False, TristateUseDefault)
MsgBodyText2 = MsgBody2.ReadAll
MsgBody2.Close

MsgBodyText = MsgBodyText1 & Chr(13) & MsgBodyText2

Set MyOutlook = New Outlook.Application
Set MyMail = MyOutlook.CreateItem(olMailItem)

With MyMail
.Subject = SubjectLine$
.HTMLBody = MsgBodyText
.Display
End With


End Function
 
How are ya Rjc8513 . . .

Try:
Code:
[blue]   MsgBodyText = MsgBodyText1 & vbNewLine & MsgBodyText2[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks AceMan, but that didn't work. I still only get the first report to show up in the body of the message.
 
I have nine separate html files which I paste into the body of an e-mail message in Outlook.

You are probably actually posting the display from the browser (which includes some html code) into Outlook.
Your code here appears to be including 9 complete html files into the body of the message. i.e. 9 head tags, 9 body tags, 9 </html> tags, etc.

You might try parsing the .htm files to only include everything between the <body> and </body> tags, but I wouldn't bet on a perfect result.

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
I neglected to post that using the code above, the first of these reports displays just fine, with the HTML formatting intact, in the body of the email message. But, the second will not display.

Any other ideas? Thanks.

 
rjc8513 said:
I neglected to post that using the code above, the first of these reports displays just fine, with the HTML formatting intact, in the body of the email message. But, the second will not display.

Not surprising. That is very likely because when it get to the end of the first embedded html file with rows something like:
Code:
...
</body>
</html>
that Outlook (more or less correctly) thinks it's done because it's processed an html closing tag.

Greg
People demand freedom of speech as a compensation for the freedom of thought which they seldom use. Kierkegaard
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top