I've created a rule in Outlook that automatically moves incoming messages to a folder and runs a script to modify the subject.
This is the rule:
and here is my script:
Public Sub RemoveIrDateTime(Item As Outlook.MailItem)
'Item As Outlook.MailItem
'stringToMatch = "issued at 11/14/17 6:28 PM"
Set issuedMsg = New RegExp
Set priSev = New RegExp
Set iR = New RegExp
With issuedMsg
.Pattern = "issued at \d{1,2}/\d{1,2}/\d\d .+"
.Global = True
End With
With priSev
'.Pattern = "^P\d/S\d - IR"
.Pattern = "^.+IR"
.Global = True
End With
Item.Subject = issuedMsg.Replace(Item.Subject, "")
Item.Subject = priSev.Replace(Item.Subject, "IR")
'Item.Subject = Left(EmItemail.Subject, 60)
Item.Save
End Sub
When a matching message arrives, it gets moved to the designated folder, but the subject does not get updated.
However, if I use the 'Manage rules & Alerts' option, and run my rule against the target folder 'Incidents', then the subject of the emails in the folder gets updated as I expect.
Is there a bug in Outlook such that moving the message prevents the script from running? any ideas on how to resolve?