Dear all,
I need some piece of advice. I am using the following code to strip message subjects of such words, as example {EXTERNAL}", "HA:", "[Ext]", "[EXTERNAL] and so on. Location is in ThisSession of Outlook.
I use the rule such as "with specific words in the subject"and "run a script".
I use Office 2013, Exchange Server. The account is set up on two computers, one PC is working station within active directory / domain. The 2nd computer is a laptop with the same accout, out of active directory / domain.
The rule and the script works fine, the only issue, from time to time it prompts an error and stop executing teh script. This happens both either on PC or laptop. Screenshots are attached.
Sub RemoveSubjectResidual(oItem As Outlook.MailItem)
On Error GoTo ErrHandler
Dim arr As Variant, i As Long
arr = Array("FW:", "Re:", "{EXTERNAL}", "HA:", "[Ext]", "[EXTERNAL]")
For i = 0 To UBound(arr)
oItem.Subject = Replace(oItem.Subject, arr(i), "", , , vbTextCompare)
Next
oItem.Subject = Trim(oItem.Subject)
oItem.Save
Exit Sub
ErrHandler:
MsgBox "Oops, an error has occured." & vbCrLf & vbCrLf & "Error Code : " & Err.Number & " , " & Err.Description
End Sub
I need some piece of advice. I am using the following code to strip message subjects of such words, as example {EXTERNAL}", "HA:", "[Ext]", "[EXTERNAL] and so on. Location is in ThisSession of Outlook.
I use the rule such as "with specific words in the subject"and "run a script".
I use Office 2013, Exchange Server. The account is set up on two computers, one PC is working station within active directory / domain. The 2nd computer is a laptop with the same accout, out of active directory / domain.
The rule and the script works fine, the only issue, from time to time it prompts an error and stop executing teh script. This happens both either on PC or laptop. Screenshots are attached.
Sub RemoveSubjectResidual(oItem As Outlook.MailItem)
On Error GoTo ErrHandler
Dim arr As Variant, i As Long
arr = Array("FW:", "Re:", "{EXTERNAL}", "HA:", "[Ext]", "[EXTERNAL]")
For i = 0 To UBound(arr)
oItem.Subject = Replace(oItem.Subject, arr(i), "", , , vbTextCompare)
Next
oItem.Subject = Trim(oItem.Subject)
oItem.Save
Exit Sub
ErrHandler:
MsgBox "Oops, an error has occured." & vbCrLf & vbCrLf & "Error Code : " & Err.Number & " , " & Err.Description
End Sub