Hi,
I currently have a macro that creates personalised Emails i.e. Dear John, and then sends them out to a recipient list which it reads from a CSV file (it does other stuff as well but this is the lead into my problem). I want the Email body to come up in a specific format with a company logo, I have created the Email body with word and saved it as both HTML and RTF format, the HTML format does not display correctly as all of the logo's etc are saved as separate files on my PC and are not sent with the mail so I thought I would try it with RTF as all of the data is saved in a single file.
I have created the below macro to try and test just sending the RTF but it comes back with "Run-time error Method 'RTFBody of object _MailItem' failed". I have tried converting it but the array it is stored in is already a string so it should be the right type. Any ideas?
Code:
Sub RTF_email()
Dim EmailHTMLFile As Integer
Dim EmailHTMLFilePath As String
Dim newFileContents As String
Dim OutApp As Object
Dim OutMail As Object
EmailHTMLFilePath = "D:\Stuff\Email template.rtf"
EmailHTMLFile = FreeFile()
Open EmailHTMLFilePath For Input As #EmailHTMLFile
'Reading the Email contents into an array which e are going to use and manipulate from here
newFileContents = Input$(LOF(EmailHTMLFile), #EmailHTMLFile)
Close #EmailHTMLFile
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
' Change the mail address and subject in the macro before you run this procedure.
'On Error Resume Next
With OutMail
.to = "mlw@sierrawireless.com"
.CC = ""
.BCC = ""
.Subject = "Test Email"
.BodyFormat = 3
.RTFBody = newFileContents
.Display
End With
End Sub
Regards
Matt