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 = fspenTextFile(MsgBodyFile1, ForReading, False, TristateUseDefault)
MsgBodyText1 = MsgBody1.ReadAll
MsgBody1.Close
Set MsgBody2 = fspenTextFile(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
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 = fspenTextFile(MsgBodyFile1, ForReading, False, TristateUseDefault)
MsgBodyText1 = MsgBody1.ReadAll
MsgBody1.Close
Set MsgBody2 = fspenTextFile(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