在 Outlook 2010 中使用模板回复

问题描述 投票:0回答:4

作为在帮助台改进客户服务的持续过程,我希望在我们的 Outlook 中集成一项功能,以便我们可以使用 Outlook 模板 (.oft) 回复现有电子邮件。

我的在线搜索大多为我提供了自动回复的结果。然而这不是我(我们)所需要的。

我们需要一种工具,使我们能够从标准模板列表中进行选择(带有面向主题的回复)。 http://replywith.4team.biz/ 提供了正确方向的解决方案,但是,与任何公司一样,我们需要一个免费工具。

这可以在 VBA 中编程吗?如果是这样,怎么办?

vba outlook outlook-2010
4个回答
2
投票

VBA示例基于http://msdn.microsoft.com/en-us/library/office/ff865637.aspx

Sub CreateReplyFromTemplate() 
 
    dim currItem  As Outlook.MailItem 
    dim currItemReply  As Outlook.MailItem 
    Dim MyItem As Outlook.MailItem 
 
    set currItem = activeinspector.currentitem
    Set curritemReply = currItem.Reply
    Set MyItem = Application.CreateItemFromTemplate("C:\HelpTopic1.oft") 

    MyItem.To = currItemReply.To
    MyItem.htmlbody = MyItem.htmlbody  & currItemReply.htmlbody

    currItemReply.close oldiscard
    currItem.close  oldiscard

    MyItem.Display 

    set curritemReply = nothing
    set MyItem = nothing
    set currItem = nothing
End Sub

部署 VbaProject.OTM 文件VbaProject.OTM 部署

通过快速步骤回复消息模板 - http://www.msoutlook.info/question/665

使用消息模板 - http://www.howto-outlook.com/howto/messagetemplates.htm


0
投票

当然你可以在 VBA 中做到这一点,但你真的想要吗?您可以花 99.50 美元购买该工具的 10 个许可证。我不知道你在哪里工作,但在大多数软件公司,99.50 美元可以为你购买大约一个小时的程序员时间(包括福利)。如果您节省了发布此问题所花费的时间,您可能已经购买了 1 个许可证。


0
投票

只是添加到上面的答案,在子 CreateReplyFromTemplate() 而不是

Set curritemReply = currItem.Reply

替换为

Set currItem = Application.ActiveExplorer().Selection(1)

0
投票

我正在尝试做同样的事情,是的,这是可能的。 我有两个版本的代码,一个为您提供一个输入框并允许您键入模板名称并检索它们适用于回复。另一个应该是同样的事情,但使用用户表单,以便用户可以选择任何模板并在漂亮的菜单中单击一次即可应用它们。不幸的是,第二个代码被破坏了(按钮和用户窗体与模块交互的问题),但文本输入工作正常!

Sub AUTOS1()
Dim objItem As Object
Dim mail As MailItem
Dim replyall As MailItem
Dim templateItem As MailItem
Dim templatePath As String
Dim templates As New Scripting.Dictionary
Dim templateName As String

'Add the names and full paths of the templates you want to use here
templates.Add "Shipping", ("C:\Users\user02\AppData\Roaming\Microsoft\Templates\Shipping.oft")
templates.Add "Preadvice", ("C:\Users\example\AppData\Roaming\Microsoft\Templates\PreAdvice.oft")
templates.Add "Documents", ("C:\Users\user02\AppData\Roaming\Microsoft\Templates\Documents.oft")

'Displays a dialog box asking the user to enter the name of the template
templateName = InputBox("Enter the name of the template you want to use:")

'Retrieves the full path of the template from the name entered by the user
If templates.Exists(templateName) Then
    templatePath = templates(templateName)
Else
    MsgBox "Template not found."
    Exit Sub
End If

'Opens the selected template
Set templateItem = Application.CreateItemFromTemplate(templatePath)

For Each objItem In ActiveExplorer.Selection
    If objItem.Class = olMail Then
        Set mail = objItem
        Set replyall = mail.replyall
        'Adds the contents of the template to the body of the reply message
        replyall.HTMLBody = templateItem.HTMLBody & replyall.HTMLBody
        replyall.Display
    End If
Next
End Sub

记得允许宏并确保启用 outlook、脚本服务等引用

© www.soinside.com 2019 - 2024. All rights reserved.