跳到主要内容

当您在Outlook中忙碌时如何自动回复收到的邮件?

有时,您想在一段时间内忙碌时自动回复Outlook中收到的消息。 但是没有内置函数可以处理此工作,但是,这里有一个VBA代码可以处理它。

忙于使用VBA代码时自动回复


忙于使用VBA代码时自动回复

Office 选项卡 - 在 Microsoft Office 中启用选项卡式编辑和浏览,让工作变得轻而易举
Kutools for Outlook - 通过 100 多个高级功能增强 Outlook,实现卓越效率
使用这些高级功能增强您的 Outlook 2021 - 2010 或 Outlook 365。 享受全面的 60 天免费试用并提升您的电子邮件体验!

这是一个VBA代码,当Outlook日历中有一些约会时,它将自动答复,如果日历中没有任何内容,它将停止自动答复。

1。 按 Alt + F11键 打开钥匙 Microsoft Visual Basic应用程序 窗口。

2.双击 本次展望会议 来自 Project1 窗格,将下面的代码复制并粘贴到脚本中。

VBA:忙于日历时自动回复

Public WithEvents xInboxItems As Outlook.Items

Private Sub Application_Startup()
Set xInboxItems = Outlook.Application.Session.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub xInboxItems_ItemAdd(ByVal Item As Object)
'UpdatebyExtendoffice20180418
Dim xMailItem As Outlook.MailItem
Dim xReplyMailItem As Outlook.MailItem
Dim xReplyHTMLBody As String
Dim xAppointments As Outlook.Items
Dim xFilter As String
Dim xRestrictAppointments As Outlook.Items
Dim xAppointment As Outlook.AppointmentItem
Dim xDateFormat As String
On Error Resume Next
If TypeOf Item Is MailItem Then
    Set xMailItem = Item
    Set xReplyMailItem = xMailItem.Reply
    xReplyHTMLBody = xReplyMailItem.HTMLBody
    Set xAppointments = Outlook.Application.Session.GetDefaultFolder(olFolderCalendar).Items
    xAppointments.Sort "[Start]"
    xAppointments.IncludeRecurrences = True
    xDateFormat = Format(Now, "ddddd h:nn AMPM")
    xFilter = "[Start]<= '" & xDateFormat & "' AND [End]>= '" & xDateFormat & "'"
    Set xRestrictAppointments = xAppointments.Restrict(xFilter)
    If TypeName(xRestrictAppointments) = "Nothing" Then Exit Sub
    For Each xAppointment In xRestrictAppointments
        If xAppointment.BusyStatus = olBusy Or olOutOfOffice Then
            xReplyMailItem.HTMLBody = "<HTML><BODY>I'm Sorry that I can't respond to you right now. I'll reply to you later.</HTML></BODY>" & _
                                      xReplyHTMLBody
            xReplyMailItem.Send
        End If
    Next
End If
End Sub

3.保存此代码,然后重新启动Outlook。 从现在开始,如果在您指定的时间范围内收到电子邮件,则会发送自动回复。

提示:

(1)在代码中,您可以根据需要在此脚本中更改回复正文 “很抱歉,我现在无法回复您。稍后我会回复您。” &_

(2)此VBA宏可以自动回复默认数据文件收件箱中收到的电子邮件。


最佳办公生产力工具

Kutools for Outlook - 超过 100 种强大功能可增强您的 Outlook

🤖 人工智能邮件助手: 具有人工智能魔力的即时专业电子邮件——一键天才回复、完美语气、多语言掌握。轻松改变电子邮件! ...

📧 电子邮件自动化: 外出(适用于 POP 和 IMAP)  /  安排发送电子邮件  /  发送电子邮件时按规则自动抄送/密件抄送  /  自动转发(高级规则)   /  自动添加问候语   /  自动将多收件人电子邮件拆分为单独的消息 ...

📨 电子邮件管理: 轻松回忆电子邮件  /  按主题和其他人阻止诈骗电子邮件  /  删除重复的电子邮件  /  高级搜索  /  合并文件夹 ...

📁 附件专业版批量保存  /  批量分离  /  批量压缩  /  自动保存   /  自动分离  /  自动压缩 ...

🌟 界面魔法: 😊更多又漂亮又酷的表情符号   /  使用选项卡式视图提高 Outlook 工作效率  /  最小化 Outlook 而不是关闭 ...

👍 一键奇迹: 使用传入附件回复全部  /   反网络钓鱼电子邮件  /  🕘显示发件人的时区 ...

👩🏼‍🤝‍👩🏻 通讯录和日历: 从选定的电子邮件中批量添加联系人  /  将联系人组拆分为各个组  /  删除生日提醒 ...

超过 100特点 等待您的探索! 单击此处了解更多。

了解更多       免费下载      购买
 

 

Comments (1)
No ratings yet. Be the first to rate!
This comment was minimized by the moderator on the site
Hi
How to modify your VBA code for taking into account only all day events with specific names, pls?I've no clue in coding... :(
Thank you in advance.
BR
There are no comments posted here yet
Please leave your comments in English
Posting as Guest
×
Rate this post:
0   Characters
Suggested Locations