Sometimes, you may forget to reply some important emails. Therefore, in this post, we will expose you a piece of VBA code, which will auto check if there are any vital emails that you haven’t replied as closing Outlook. If there are, you’ll get warned.
At times, it is inevitable that you may forget to reply some emails. Provided that the emails are extremely significant, such as from your boss or your clients, the consequences can be considerably serious. Therefore, here we will introduce you a method, which can make Outlook auto warn you if you forget to reply any vital emails when you close your Outlook.
Get Warned If Forgetting to Reply Important Emails When Closing Outlook
- In the first place, start your Outlook application.
- Then press “Alt + F11” key buttons to get access to Outlook VBA editor.
- Next in the new “Microsoft Visual Basic for Applications” window, you need to find and open the “ThisOutlookSession” project.
- Subsequently, you ought to copy the following VBA code into this project.
Private Sub Application_Quit() Dim objInboxFolder As Outlook.Folder Dim objMail As Outlook.MailItem Dim i, n As Long Dim objPropertyAccessor As Outlook.propertyAccessor Dim strRepliedStatus As String Dim nDateDiff As Integer Dim strMailList As String Dim strMsg As String Dim nWarning As Integer Set objInboxFolder = Outlook.Application.Session.GetDefaultFolder(olFolderInbox) n = 0 For i = objInboxFolder.Items.Count To 1 Step -1 Set objMail = objInboxFolder.Items.Item(i) DoEvents If TypeOf objMail Is MailItem Then 'Set the criteria for important emails as per your needs 'Such as from specific sender or subject containing specific words If objMail.SenderEmailAddress = "email@example.com" And InStr(LCase(objMail.Subject), "datanumen") > 0 Then 'Check if the email is replied or not Set objPropertyAccessor = objMail.propertyAccessor strRepliedStatus = objPropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x10810003") If (Not (strRepliedStatus = 102)) And (Not (strRepliedStatus = 103)) Then 'Only work for the recent incoming emails 'Received within 12 hours nDateDiff = DateDiff("h", objMail.ReceivedTime, Now) If nDateDiff < 12 Then n = n + 1 strMailList = strMailList & n & ". " & objMail.Subject & vbCrLf strMsg = "You may forget to reply some important emails, as follows:" & vbCrLf & vbCrLf & strMailList & vbCrLf & "You had better restart your Outlook to reply them!" End If End If End If End If Next If strMailList <> "" Then nWarning = MsgBox(strMsg, vbExclamation + vbOKOnly, "Outlook Warning") End If End Sub
- After that, you have to sign this code and continue to change your Outlook macro settings to permit the digitally signed macros.
- Finally you can have a try. Just close your Outlook by clicking the cross icon in the top right corner.
- If there are some important emails which are not replied, you’ll get a warning like the screenshot below:
Prevent PST Data Loss
Since Outlook is vulnerable to crash, your PST file is in danger all the time. Thus, you should spend some energy safeguarding your PST data, like making regular PST data backups and keeping a potent PST data recovery tool in vicinity, such as DataNumen Outlook Repair. It is able to fix Outlook errors and extract maximum data from corrupt PST file without breaking a sweat.
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including corrupt SQL Server and outlook repair software products. For more information visit www.datanumen.com