• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Remove text in subject using VBA


New Member
Outlook version
Outlook 2013 64 bit
Email Account
Exchange Server

In my company there has been made a new feature whenever we get an email from an external sender.

Text i subject can now be: "[CAUTION: EXTERNAL EMAIL] Agenda for meeting wednesday" as before it would just have stated "Agenda for meeting wednesday"

The annoying thing about it is that the text [CAUTION: EXTERNAL EMAIL] does not remove itself when I send a reply.
I would like af code to put into ThisOutlookSession.

I have tried this one but without luck:

Sub mymacro ()
dim arr as variant,i as long
for i=0 to ubound(arr)
End Sub

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
is that the only test you need to replace? if so, don't use the arrary.
oitem.subject=replace(oitem.subject,"[CAUTION: EXTERNAL EMAIL]","")

if you want ot use an array, see Using Arrays in Outlook macros
try For i = LBound(arr) To UBound(arr)