使用您的文本保存模板文件。在代码中,它保存到C驱动器并命名为NamePlaceholder.oft。根据需要改变。
在运行代码之前打开请求。
Sub CreateReplyFromTemplate()
Dim currItem As Outlook.mailItem
Dim currItemReply As Outlook.mailItem
Dim myItem As Outlook.mailItem
Dim commaPositionRight As Long
Dim Firstname As String
Set currItem = ActiveInspector.currentItem
Set currItemReply = currItem.Reply
Set myItem = Application.CreateItemFromTemplate("C:\NamePlaceholder.oft")
myItem.To = currItemReply.To
commaPositionRight = InStrRev(myItem.To, ",")
Firstname = Right(myItem.To, commaPositionRight)
myItem.Subject = currItem.Subject
' if "RE:" or "FW:" on the request,
' and the client replies there would be an extra "RE:" or "FW:"
If InStr(myItem.Subject, "RE: ") = 1 Or InStr(myItem.Subject, "FW: ") = 1 Then
myItem.Subject = Right(myItem.Subject, Len(myItem.Subject) - 4)
End If
myItem.HTMLBody = myItem.HTMLBody & currItemReply.HTMLBody
myItem.HTMLBody = Replace(myItem.HTMLBody, "NAME", Firstname)
currItemReply.Close olDiscard
currItem.Close olDiscard
myItem.Display
Set currItemReply = Nothing
Set myItem = Nothing
Set currItem = Nothing
End Sub
如果您不熟悉VBA,请看这里 http://www.slipstick.com/developer/how-to-use-outlooks-vba-editor/