Is it possible to open an Outlook template file (.oft) and then populate the To, Subject and Body using vba.
I have the following code
Private Sub CreateEMail()
Dim oApp As New Outlook.Application
Dim oEmail As Outlook.MailItem
Set oEmail = oApp.CreateItemFromTemplate("C:\Outlook Templates\Template.oft")
'oEmail.To = "anaddress@gmail.com"
'oEmail.Subject = "Testing using the template"
'oEmail.HTMLBody = "Testing where this appears in the template"
' in reality these would be text items from a form e.g. me.txtbody.value
oEmail.Display
End Sub
With the .To, .Subject and .HTMLBody commented out the Outlook template file opens correctly
With those code lines un-commented the template is ignored and a 'standard' Outlook window opens correctly filled in.
My template has Corporate details in the Body(Message) section and a disclaimer notice to appear at the bottom of the e-mail.
A secondary question then arises, which is, if it is possible to pass the .HTMLBody item in code, is it possible to control where it appears in the email message.
I am imagining something like 'fields' in the template into which I pass the required text items much like one would do a mail merge in Word.