How to automatically reply to received messages when you are busy in Outlook?
Sometimes, you want to automatically reply to the received messages in Outlook while you are busy in a period. But there is no built-in function that can handle this job, however, here I have a VBA code to deal with it.
Auto reply when you are busy with a VBA code
Auto reply when you are busy with a VBA code
Here is a VBA code, which will auto reply while there are some appointments in your Outlook calendar, if there is nothing in the calendar, it stops automatically replying.
1. Press Alt + F11 keys to open Microsoft Visual Basic for Applications window.
2. Double click at ThisOutlookSession from the Project1 pane, copy and paste below code to the script.
VBA: Autoreply while you are busy in calendar
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. Save this code and restart the Outlook. From now on, if the emails are receiving in the time range of your appointments, an auto reply will be sent.
Tips:
(1) In the code, you can change the reply body as you need in this script "I'm Sorry that I can't respond to you right now. I'll reply to you later." & _
(2) This VBA macro can automatically reply emails received in the Inbox of default data file.
AI Mail Assistant in Outlook: Smarter Replies, Clearer Communication (one-click magic!) FREE
Streamline your daily Outlook tasks with the AI Mail Assistant from Kutools for Outlook. This powerful tool learns from your past emails to offer intelligent and accurate responses, optimize your email content, and help you draft and refine messages effortlessly.
This feature supports:
- Smart Replies: Get responses crafted from your past conversations—tailored, precise, and ready to go.
- Enhanced Content: Automatically refine your email text for clarity and impact.
- Effortless Composition: Just provide keywords, and let AI handle the rest, with multiple writing styles.
- Intelligent Extensions: Expand your thoughts with context-aware suggestions.
- Summarization: Get concise overviews of long emails instantly.
- Global Reach: Translate your emails into any language with ease.
This feature supports:
- Smart email replies
- Optimized content
- Keyword-based drafts
- Intelligent content extension
- Email summarization
- Multi-language translation
Best of all, this feature is completely free forever! Don’t wait—download AI Mail Assistant now and enjoy!
Best Office Productivity Tools
Breaking News: Kutools for Outlook Launches Free Version!
Experience the all-new Kutools for Outlook FREE version with 70+ incredible features, yours to use FOREVER! Click to download now!
📧 Email Automation: Auto Reply (Available for POP and IMAP) / Schedule Send Emails / Auto CC/BCC by Rules When Sending Email / Auto Forward (Advanced Rules) / Auto Add Greeting / Automatically Split Multi-Recipient Emails into Individual Messages ...
📨 Email Management: Recall Emails / Block Scam Emails by Subjects and Others / Delete Duplicate Emails / Advanced Search / Consolidate Folders ...
📁 Attachments Pro: Batch Save / Batch Detach / Batch Compress / Auto Save / Auto Detach / Auto Compress ...
🌟 Interface Magic: 😊More Pretty and Cool Emojis / Remind you when important emails come / Minimize Outlook Instead of Closing ...
👍 One-click Wonders: Reply All with Incoming Attachments / Anti-Phishing Emails / 🕘Show Sender's Time Zone ...
👩🏼🤝👩🏻 Contacts & Calendar: Batch Add Contacts From Selected Emails / Split a Contact Group to Individual Groups / Remove Birthday Reminders ...