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

Strip Text from Subject Line

Outlook version
Outlook 2007
Email Account
I need a macro that will delete various text phrases that get inserted into the subject line of email.

Text phases like: , RE: , UNCLASS, FW: , Fwd, and several more.

I found a macro on this website (cannot remembber the author) that will remove a single occurrence of a text phrase. In this case the macro removes the phrase "RE: " from the subject line.

'Code to Remove string "RE1:_" from subject line - RE1: with single space
Sub StripSubjectRE1(oItem As Outlook.MailItem)
Dim iDeleteRE1 As Integer
Dim sDeleteRE1 As String
Dim sOldRE1 As String
Dim sNewRE1 As String

iDeleteRE1 = 0
sDeleteRE1 = "RE: "

With oItem
sOldRE1 = .Subject
iDeleteRE1 = InStr(1, .Subject, sDeleteRE1, vbTextCompaRE1)

If iDeleteRE1 <> 0 Then
sNewRE1 = Replace(sOldRE1, sDeleteRE1, "", 1, -1, vbTextCompare)
.Subject = Trim(sNewRE1)
End If
End With
End Sub

I would like a single macro that will handle a list of several text phrases.

Can anyone help me with this?


Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
You can replace all the code between sub & end sub by this one
dim arr as variant,i as long
arr=array("phrase 1", "phrase2", "etc")
for i=0 to ubound(arr)
Outlook version
Outlook 2007
Email Account
Thanks Michael, it works fine!

by the way, how many phrases can I insert in the ARR=ARRAY(..... line?


Similar threads