In Outlook calendar, you can show your appointments as busy, tentative, free or out of office. This article will teach you how to make Outlook auto reply the incoming emails when you are busy or out of office.
As you can see, you’re permitted to show your appointments or meetings as busy, tentative, free or out of office. Therefore, by this means, you can set the busy/free information of specific time intervals in your calendar. If you are accustomed to use this feature, you may hope that Outlook can automatically reply the incoming emails when you are busy or out of office. Hence, here we will introduce how to use VBA to let Outlook auto check your busy/free information of current time when an incoming email arrives in your mailbox. If you are busy or out of office, Outlook will auto send a reply.
Auto Reply the Incoming Email When You Are Busy or Out of Office
- In the first place, start your Outlook application.
- Then you need to enter VBA editor window, either by clicking on the “Visual Basic” button under “Developer” tab or pressing “Alt + F11” keys.
- Next open the “ThisOutlookSession” project window.
- Subsequently, copy and paste the following VBA codes into it.
Public WithEvents objItems As Outlook.Items Private Sub Application_Startup() Set objItems = Outlook.Application.Session.GetDefaultFolder(olFolderInbox).Items End Sub Private Sub objItems_ItemAdd(ByVal Item As Object) Dim objMail As Outlook.MailItem Dim objAutoReply As Outlook.MailItem Dim strReplyBody As String Dim objAppointments As Outlook.Items Dim strFilter As String Dim objRestrictAppointments As Outlook.Items Dim objAppointment As Outlook.AppointmentItem If Item.Class = olMail Then Set objMail = Item Set objAutoReply = objMail.Reply strReplyBody = objAutoReply.HTMLBody Set objAppointments = Outlook.Application.Session.GetDefaultFolder(olFolderCalendar).Items objAppointments.Sort "[Start]" objAppointments.IncludeRecurrences = True strFilter = "[Start]<= '" & Format(Now, "ddddd h:nn AMPM") & "' AND [End]>= '" & Format(Now, "ddddd h:nn AMPM") & "'" 'Find the appointments occurring currently Set objRestrictAppointments = objAppointments.Restrict(strFilter) If Not (objRestrictAppointments Is Nothing) Then For Each objAppointment In objRestrictAppointments 'Check the busy/free information If objAppointment.BusyStatus = olBusy Or olOutOfOffice Then objAutoReply.HTMLBody = "<HTML><BODY>I'm SORRY that I can't respond to you right now. I'll reply to you later.</HTML></BODY>" & strReplyBody End If Next objAutoReply.Send End If End If End Sub
- After that, sign this code as usual.
- Later change your Outlook macro settings to permit the signed macros only.
- Finally restart your Outlook to activate the new VBA project.
- From now on, every time a new email lands into your Inbox folder, Outlook will auto check the busy/free information of the current time. If you are busy or out of office, Outlook will auto send out a reply, like the following image.
Cope with Frequent PST Errors
Perhaps you have been plagued by various PST issues for long time in Outlook. It is recommended that you had better make some precautions and prepare some solutions. For instance, you have to back up your PST data on a regular basis. In addition, you should get hold of a robust repair tool, such as DataNumen Outlook Repair, which can fix PST issues effectively without breaking a sweat.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including corrupted mdf and outlook repair software products. For more information visit www.datanumen.com