vba 在 Outlook 中以编程方式回复电子邮件

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15233475/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-11 19:53:21  来源:igfitidea点击:

Programmatically reply to an email in Outlook

vbaoutlookoutlook-2010outlook-vba

提问by apatton.cnet

I'm writing a script that replies to every email coming in.

我正在编写一个脚本来回复每封收到的电子邮件。

I have made a rule to run on all incoming messages that runs a script, sets the category, and marks as read. The rule sets the category and marks as read, but doesn't run the script. Below is my code:

我制定了一个规则来运行所有运行脚本、设置类别和标记为已读的传入消息。该规则将类别和标记设置为已读,但不运行脚本。下面是我的代码:

Sub reply(Item As Outlook.MailItem)

    MsgBox "Hey this script is running!"

    On Error GoTo ErrorTrap

    Dim MsgReply As Outlook.MailItem
    Set MsgReply = Item.reply
    With MsgReply
        .Subject = "Welcome to IT Business Builder"
        .HTMLBody = "This is just a test"
        .Body = "This is just a test"
        .Send
    End With
    Set MsgReply = Nothing
ErrorTrap:
    MsgBox Err.Number & " " & Err.Description & " message not sent because of error"

End Sub

After running the rule, no message box pops up, no emails are sent.

运行规则后,不弹出消息框,不发送电子邮件。

回答by Sandesh Jadhav M

If your email does not change each time. You can use Outlooks inbuilt feather of auto reply. It sends the given email to all of them who send an email to your email ID.

如果您的电子邮件不是每次都更改。您可以使用 Outlooks 内置的自动回复功能。它将给定的电子邮件发送给所有向您的电子邮件 ID 发送电子邮件的人。

Click Here to See how to set it up

单击此处查看如何设置

To quickly summarise...

快速总结...

  1. Create a new message with subject and body you want to send as auto replying.
  2. Click File (in Outlook 2007, click the Office button) > Save As.
  3. In the Save As dialog box, select Outlook Template in the Save as type drop-down list, and then click the Save button.
  4. Close the message directly. If you are using Outlook 2010, 2013 and 2016, please click Home > Rules > Manage Rules & Alerts.
  1. 创建一个带有您要作为自动回复发送的主题和正文的新消息。
  2. 单击文件(在 Outlook 2007 中,单击 Office 按钮)> 另存为。
  3. 在另存为对话框中,在另存为类型下拉列表中选择 Outlook 模板,然后单击保存按钮。
  4. 直接关闭消息。如果您使用的是 Outlook 2010、2013 和 2016,请单击“主页”>“规则”>“管理规则和警报”。

For Outlook 2007, click Tools > Rules and Alerts... from the menu in Outlook window. See screenshot:

对于 Outlook 2007,从 Outlook 窗口的菜单中单击工具 > 规则和警报...。看截图:

  1. In the Rules and Alerts dialog box, click New Rule...
  2. In the Rules Wizard dialog box, select Apply rule on message I receive in Outlook 2010 and 2013. And In Outlook 2007, select the Start from a blank rule option and the Check messages when they arrive option, and click Next button.
  3. In the following Rules Wizard dialog box, select sent only to me in Outlook 2010 and 2013, or select where my name is in the To box in Outlook 2007, and then click Next button.
  4. Check reply using a specific template under Select action(s), and click on a specific template in the Edit the rule description box. See screenshot:
  5. In the Select a Reply Template dialog box, select User Templates in File System in the Look In drop-down list, select the template you created before and click the Open button. When it returns to the previous Rules Wizard dialog box, click the Next button.
  6. In the next Rules and Wizard dialog box, click the Next button without checking any exceptions.
  7. Type a name for your auto reply rule in the Specify a name for this rule box, and click the Finish button.
  1. 在规则和警报对话框中,单击新建规则...
  2. 在规则向导对话框中,选择对我在 Outlook 2010 和 2013 中收到的邮件应用规则。在 Outlook 2007 中,选择从空白规则开始选项和邮件到达时检查选项,然后单击下一步按钮。
  3. 在下面的规则向导对话框中,在 Outlook 2010 和 2013 中选择仅发送给我,或在 Outlook 2007 的收件人框中选择我的名字所在的位置,然后单击下一步按钮。
  4. 在 Select action(s) 下检查使用特定模板的回复,然后单击 Edit the rule description 框中的特定模板。看截图:
  5. 在“选择回复模板”对话框中,在“查找范围”下拉列表中选择“文件系统中的用户模板”,选择您之前创建的模板并单击“打开”按钮。当它返回到上一个规则向导对话框时,单击下一步按钮。
  6. 在下一个规则和向导对话框中,单击下一步按钮而不检查任何异常。
  7. 在“为此规则指定名称”框中键入自动回复规则的名称,然后单击“完成”按钮。

If you want to use this rule for all email accounts, please check the Create this rule on all accounts box.

如果您想对所有电子邮件帐户使用此规则,请选中在所有帐户上创建此规则框。

  1. Now it returns to the Rules and Alerts dialog box, please click the OK button. Now the auto reply rule is created.
  1. 现在它返回到规则和警报对话框,请单击确定按钮。现在自动回复规则已创建。