I scoured the Outlook VBA section of the site, and could not find anything related.
I created a template. The formatting is as I want it and the signature auto-populates.
I created a macro that replaces tags in the message with information entered in Input Boxes.
I tried using myItem.Body
in my replace function. I lose all template and signature formatting.
I tried using myItem.HTMLBody
in my replace function. It does not replace anything in the body and the signature disappears.
Code (Outlook 2010)
Sub PopulateTemplate()
Dim myItem As MailItem, oInspector As Inspector
Set oInspector = Application.ActiveWindow
Set myItem = oInspector.CurrentItem
'Provide the email address(es) and populate in the To field
strEmailAddr = InputBox("Enter email address(es), separated by semicolon(;)")
myItem.To = Replace(myItem.To, "<EmailAddr>", strEmailAddr)
myItem.Display
'Provide the project name and populate in subject and body of email
strProjName = InputBox("Enter the Project Name")
myItem.Subject = Replace(myItem.Subject, "<ProjectName>", strProjName)
myItem.Body = Replace(myItem.Body, "<ProjectName>", strProjName)
myItem.Display
'Provide the time of day for the greeting and populate in the body of email
strTimeofDay = InputBox("Enter Morning, Afternoon, or Evening")
myItem.Body = Replace(myItem.Body, "<TimeofDay>", strTimeofDay)
myItem.Display
'Provide the first name for the greeting and populate in body of email
strContactName = InputBox("Enter the First Name for the Greeting")
myItem.Body = Replace(myItem.Body, "<ContactName>", strContactName)
myItem.Display
'Resolve all recipients (Same as pressing the "Check Names" button)
Call myItem.Recipients.ResolveAll
'Free memory
Set strEmailAddr = Nothing
Set strProjName = Nothing
Set strTimeofDay = Nothing
Set strContactName = Nothing
End Sub