How to Auto Delete a Junk Email after Marking It as Read in Your Outlook

Many users hope that Outlook is able to automatically delete a junk email after they mark it as read. Although there is not such a native function, it still can be realized with Outlook VBA. This article will show the VBA code and detailed steps.

If you’ve set Outlook junk filter level to high, Outlook will often recognize the genuine emails as junks by mistake. In this scenario, you shouldn’t empty “Junk E-mail” folder at will. You have to check every junk email before deleting so as to prevent the genuine emails from being deleted erroneously. Hence, many users wish that Outlook can auto delete the junk emails when they mark them as read. Now, in the followings, we will teach you how to realize it via VBA.

Auto Delete a Junk Email after Marking It as Read in Your Outlook

Auto Delete a Junk Email after Marking It as Read

  1. To begin with, start your Outlook program.
  2. Then, press “Alt + F11” key buttons to access Outlook VBA editor.
  3. Next, copy the VBA code below into the “ThisOutlookSession” project.
Private WithEvents objJunkFolder As Outlook.Folder
Private WithEvents objJunks As Outlook.Items

Private Sub Application_Startup()
    Set objJunkFolder = Outlook.Application.Session.GetDefaultFolder(olFolderJunk)
    Set objJunks = objJunkFolder.Items
End Sub

Private Sub objJunks_ItemChange(ByVal Item As Object)
    Dim objJunkMail As Outlook.MailItem

    If TypeOf Item Is MailItem Then
       Set objJunkMail = Item
       'When marking it as read
       If objJunkMail.UnRead = False Then
          'Delete it --> Will Move to "Deleted Items" folder
          With objJunkMail
               .UserProperties.Add "DELETE", olText
          End With
          'Permanently delete it from "Deleted Items" folder
          Call PermanentlyDelete
       End If
    End If
End Sub

Private Sub PermanentlyDelete()
    Dim objDeletedItems As Outlook.Items
    Dim objItem As Object
    Set objDeletedItems = Application.Session.GetDefaultFolder(olFolderDeletedItems).Items
    For Each objItem In objDeletedItems
        If TypeName(objItem.UserProperties.Find("DELETE")) <> "Nothing" Then
        End If
End Sub

VBA Code - Auto Delete a Junk Email after Marking It as Read

  1. After that, click into “Application_Startup” to activate this new project.
  2. Eventually, you can take a shot:
  • First off, open the “Junk E-mail” folder.
  • Then, select an unread junk email.
  • Next, right click on it and choose “Mark as Read” in the context menu.Mark a Junk Email as Read
  • Immediately, this junk email will be auto deleted permanently from your Outlook.

Eliminate Annoying Outlook Errors

Although Outlook is boasting of numerous functions, it still cannot escape from issues. That is to say, Outlook still can be subject to various troubles from time to time. If the errors are not involved with the PST data, you can simply make use of the inbox repair tool. Yet, if the issue is serious Outlook corruption, you have no alternative but to employ a well-proven external repair tool, such as DataNumen Outlook Repair, which can repair PST troubles like a cork.

Author Introduction:

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

Comments are closed.