R
rogereverest
I have been using an access2k db for sometime to email text files to contacts
held in the database. I am trying to use the same approach to send an HTML
file. All that arrives at the other end is the HTML code. I am obviously
missing something! Here is the code I'm using (which somebody on here pointed
me to many months ago). Please help - its driving me mad
Dim db As DAO.Database
Dim MailList As DAO.Recordset
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim Subjectline As String
Dim BodyFile As String
Dim fso As FileSystemObject
Dim MyBody As TextStream
Dim MyBodyText As String
Set fso = New FileSystemObject
Set MyBody = fspenTextFile(BodyFile, ForReading, False, TristateUseDefault)
MyBodyText = MyBody.ReadAll
Set MyOutlook = New Outlook.Application
Set db = CurrentDb()
Set MailList = db.OpenRecordset("MyEmailAddresses")
Do Until MailList.EOF
Set MyMail = MyOutlook.CreateItem(olMailItem)
MyMail.To = MailList("email")
MyMail.Subject = Subjectline$
MyMail.BodyFormat = olFormatHTML
MyMail.Body = MyBodyText
MyMail.BodyFormat = olFormatHTML
MyMail.Send
MailList.MoveNext
Loop
The only changes I have made are the BodyFormat lines (I've put it in twice)
Many thanks in anticipation.
held in the database. I am trying to use the same approach to send an HTML
file. All that arrives at the other end is the HTML code. I am obviously
missing something! Here is the code I'm using (which somebody on here pointed
me to many months ago). Please help - its driving me mad
Dim db As DAO.Database
Dim MailList As DAO.Recordset
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim Subjectline As String
Dim BodyFile As String
Dim fso As FileSystemObject
Dim MyBody As TextStream
Dim MyBodyText As String
Set fso = New FileSystemObject
Set MyBody = fspenTextFile(BodyFile, ForReading, False, TristateUseDefault)
MyBodyText = MyBody.ReadAll
Set MyOutlook = New Outlook.Application
Set db = CurrentDb()
Set MailList = db.OpenRecordset("MyEmailAddresses")
Do Until MailList.EOF
Set MyMail = MyOutlook.CreateItem(olMailItem)
MyMail.To = MailList("email")
MyMail.Subject = Subjectline$
MyMail.BodyFormat = olFormatHTML
MyMail.Body = MyBodyText
MyMail.BodyFormat = olFormatHTML
MyMail.Send
MailList.MoveNext
Loop
The only changes I have made are the BodyFormat lines (I've put it in twice)
Many thanks in anticipation.