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
- Automate emailing with Auto CC/BCC, Auto Forward by rules; send Auto Reply (Out of Office) without requiring an exchange server...
- Get reminders like BCC Warning when replying to all while you're in the BCC list, and Remind When Missing Attachments for forgotten attachments...
- Improve email efficiency with Reply (All) With Attachments, Auto Add Greeting or Date & Time into Signature or Subject, Reply Multiple Emails...
- Streamline emailing with Recall Emails, Attachment Tools (Compress All, Auto Save All...), Remove Duplicates, and Quick Report...
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.
Best Office Productivity Tools
Kutools for Outlook - Over 100 Powerful Features to Supercharge Your Outlook
π€ AI Mail Assistant: Instant pro emails with AI magic--one-click to genius replies, perfect tone, multilingual mastery. Transform emailing effortlessly! ...
π§ Email Automation: Out of Office (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: Easily 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 / Boost Your Outlook Productivity with Tabbed Views / 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 ...
Over 100 Features Await Your Exploration! Click Here to Discover More.