How to Limit the Number of Emails Opened at the Same Time with Outlook VBA

Keeping many emails opened at the same time can make your Outlook overloaded, leading to Outlook crash. Thus, it is suggested to limit the number of emails opened in the meantime. This post will teach you how to realize it with Outlook VBA.

Outlook is prone to crash when it gets overloaded, such as when too many emails open at the same time. Therefore, you’d better only keep limited emails open at a time. Although Outlook doesn’t support this natively, you can easily achieve it via the following means.

Limit the Number of Emails Opened at the Same Time with Outlook VBA

Limit the Number of Emails Opened at the Same Time

  1. At the very outset, start your Outlook program.
  2. Then you need to access the VBA editor. You can shift to “Developer” tab and hit the “Visual Basic” button. Or just press “Alt + F11” keys in main screen.
  3. In the subsequent “Microsoft Visual Basic for Applications” window, you can locate and open the “ThisOutlookSession” project.
  4. Next you ought to copy and paste the VBA code below into this VBA project.
Public WithEvents objInspectors As Outlook.Inspectors

Private Sub Application_Startup()
    Set objInspectors = Outlook.Application.Inspectors
End Sub

Private Sub objInspectors_NewInspector(ByVal objNewInspector As Inspector)
    Dim objInspector As Outlook.Inspector
    Dim i As Long
    Dim strMsg As String
    Dim nPrompt As Integer
    i = 0
    If objNewInspector.CurrentItem.Class = olMail Then
       If objInspectors.count > 5 Then
          For Each objInspector In objInspectors
              If objInspector.CurrentItem.Class = olMail Then
                 i = i + 1
              End If
          If i > 5 Then
             strMsg = "You're allowed to open 5 emails at the same time. The previous email is closed!"
             MsgBox strMsg, vbExclamation + vbOKOnly
             ActiveInspector.CurrentItem.Close olSave
          End If
      End If
    End If
End Sub

VBA Code - Limit the Number of Emails Opened at the Same Time

  1. After that, you should sign this macro.
  • Hit the “Tools” button in the toolbar.
  • Next select the “Digital Signature” option from the drop down list.
  • In the popup dialog box, follow the onscreen instructions to complete it.
  1. Later you can change macro settings to permit the digitally signed macros.
  2. Eventually, you can restart your Outlook application to activate the macro.
  3. From now on, every time when you intend to open the sixth emails, you’ll get a message, like the screenshot:Warning
  4. Also, the previous email will be closed automatically.

Retrieve Valuable Outlook Data

There is no denying that Outlook has quantities of remarkable features. But, it doesn’t mean it is flawless. It still cannot get away with damage. Various factors can lead to Outlook corruption. Hence, so as to recover Outlook data easier, you should back up your PST file at regular intervals. Also, a well-quality repair tool is also a matter of necessity, like DataNumen Outlook Repair.

Author Introduction:

Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including fix mdf and outlook repair software products. For more information visit

Leave a Reply

Your email address will not be published. Required fields are marked *