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.
Reply message with original attachments in outlook
|As we all known, the attached attachments will be removed from the original message when you replying a message to the recipient in Outlook. If you want to reply massage with keeping attachments, you can try Kutools for Outlook's Reply with Attachment function, it can reply one message with the original attachments, also work for all messafe. Click for 45 days free trial!|
|Kutools for Outlook: with dozens of handy Outlook add-ins, free to try with no limitation in 45 days.|
Office Tab: Enable Tabbed Editing and Browsing in Office, Just Like Chrome, Firefox, IE 8/9/10.
Classic Menu: Bring Old Menus and Toolbars Back to Office 2007, 2010, 2013, 2016 and 2019.
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.
(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.
Recommended Productivity Tools
- Complicated and repeated operations can be done a one-time processing in seconds.
- Forward multiple emails individually with one-click, and auto forward by rules.
- Auto CC/BCC every sending email and easy for customizing rules, and auto reply without requiring exchange server.
- Powerful junk emails filter, remove duplicate emails, reply with attachment, bunch of one-click operations, and so on...
- 60-day unlimited free trial. 60-day money back guarantee. 2 years free upgrade and support. Buy once, use forever.