Outlook使用模板答复所有宏 [英] Outlook Reply to All Macro using a template
问题描述
我正在尝试创建一个宏来执行全部答复"操作.使用特定模板的命令.这是我到目前为止的内容:
I'm trying to create a macro to do a "reply all" command using a specific template. This is what I have so far:
Sub my_test()
Dim mail 'object/mail item iterator
Dim replyall 'object which will represent the reply email
For Each mail In Outlook.Application.ActiveExplorer.Selection
If mail.Class = olMail Then
Set replyall = mail.replyall
With replyall
.Body = "My template from a oft file"
.Display
End With
End If
Next
End Sub
在正文中,我想使用我经常文件中的模板
In the body, I'd like to use a template which I have in a oft file
(in c:\mytemplate.oft).
我不确定如何使用模板,因此,当我在底部答复时,我想要原始电子邮件,在电子邮件正文顶部,我想从现有模板中获取文本.
I am not sure how to use my template, so when I reply in the bottom I wanted to have the original email and in the top of the email body I wanted to have the text from the existing template.
想法是使用此代码(如果可能),并将模板主体文件(文本和表格)的上下文放置在此回复电子邮件的内部(顶部).
The idea is to use this code (if possible), and place the context of the template body file (text and a table), inside of this reply email (in the top).
推荐答案
Outlook的代码.Excel标签没有明显目的.
Code for Outlook. No apparent purpose for the Excel tag.
Option Explicit
Sub my_test()
Dim objItem As Object
Dim mail As MailItem
Dim replyall As MailItem
Dim templateItem As MailItem
For Each objItem In ActiveExplorer.Selection
If objItem.Class = olMail Then
Set mail = objItem
Set replyall = mail.replyall
Set templateItem = CreateItemFromTemplate("C:\template.oft")
With replyall
.HTMLBody = templateItem.HTMLBody & .HTMLBody
.Display
End With
End If
Next
End Sub
这篇关于Outlook使用模板答复所有宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!