How to remove "RE:" or "Fwd:" or "[EXT]" from an Outlook Appointment Invitation subject line when accepting?

905 Views Asked by At

I'm using Outlook 2019 on Win10.

My company adds the prefix "[EXT]:" to the subject line of all emails received from outside our network. This includes invitations. Because of this, "[EXT]:" is in most of my calendar. It makes it hard to look at a busy calendar from my phone when 90% of the subjects start with [EXT]:

I can figure out VBA code to look for RE: or Fwd: or [EXT]: in subject lines and replace/delete them.

How do I trigger the VBA code automatically when Accept, Accept with Response, Tentative, etc. buttons/pulldowns are clicked?

1

There are 1 best solutions below

0
Eugene Astafiev On

When any of these buttons are clicked the response is sent back to the organizer and you may try to handle the ItemSend event of the Application class in Outlook which is fired whenever an Microsoft Outlook item is sent, either by the user through an Inspector (before the inspector is closed, but after the user clicks the Send button) or when the Send method for an Outlook item, such as MailItem, is used in a program.

You may also find the the Items.ItemChange event helpful, it is fired when an item in the specified collection is changed.

Public WithEvents myOlItems As Outlook.Items 
 
Public Sub Initialize_handler() 
 Set myOlItems = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderCalendar).Items 
End Sub 
 
Private Sub myOlItems_ItemChange(ByVal Item As Object)
Dim prompt As String 
 If VBA.Format(Item.Start, "h") >= "17" And Item.Sensitivity <> olPrivate Then 
   prompt = "Appointment occurs after hours. Mark it private?" 
   If MsgBox(prompt, vbYesNo + vbQuestion) = vbYes Then 
     Item.Sensitivity = olPrivate 
     Item.Display 
   End If 
 End If
End Sub

Another approach is to handle all incoming emails and remove the subject prefix. The NewMailEx event fires when a new message arrives in the Inbox and before client rule processing occurs. You can use the Entry ID returned in the EntryIDCollection array to call the NameSpace.GetItemFromID method and process the item. This event fires once for every received item that is processed by Microsoft Outlook. The item can be one of several different item types, for example, MailItem, MeetingItem, or SharingItem.