Good morning all,
I have some code that allows me to auto generate an outlook email template for my users.
I have been looking for code that will allow me to insert certain userform data into the bookmarks I have set within the email.
I have found many sites on how to put code into a Word Document, but none that would allow inserting into an email.
I tried to play around with the code, but cant massage it to fit outlook instead of word.
Can this be done?
Code
Sub NewApp()
Dim FOILocation As String
FOILocation = Application.ActiveWorkbook.Path
Dim templateLocation As String
templateLocation = FOILocation & "\Templates\"
Dim myolapp As Object
Set myolapp = CreateObject("Outlook.Application")
myolapp.session.Logon
' test email
Set itemCA = myolapp.CreateItemFromTemplate(templateLocation & "Self - FOI Identification Received.oft")
With itemCA
.SentOnBehalfOfName = "[EMAIL="[email protected]"][email protected][/EMAIL]"
.to = Email
.Subject = "Identification Received - " & formFile.txtSurname & " - Ref: " & formFile.txtTrack
' this is some bad coding to get the bookmark in .. 'Staff' is the name of the bookmark
.Item("Staff").Range.InsertAfter formFile.cboAuthor.Text
End With
itemCA.Display
End Sub
Display More