我想知道这是否可能?我收到的电子邮件中必须回复以下消息
Hello NAME,
Your request has been completed.
Thank you.
有没有办法让我通过单击按钮自动完成此过程?还有,有没有办法让我用发件人姓名填充 NAME?目前,发件人姓名显示在“发件人”字段中,如下所示:LastName、FirstName。我想将邮件中的 NAME 变量替换为 FirstName 值。
我想知道 Outlook 2003 是否可以实现这一点?
任何帮助将不胜感激。
谢谢。
答案1
用您的文本保存一个模板文件。在代码中,它被保存到 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/