Strip Text from Subject Line

Outlook version
Outlook 2007
Email Account
POP3
#1
Hi,
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)
.Save
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?

Thanks,
Phil
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
#2
You can replace all the code between sub & end sub by this one
Code:
dim arr as variant,i as long
arr=array("phrase 1", "phrase2", "etc")
for i=0 to ubound(arr)
  oitem.subject=replace(oitem.subject,arr(i),"",,,vbtextcompare)
next
oitem.subject=trim(oitem.subject)
oitem.save
 
Outlook version
Outlook 2007
Email Account
POP3
#3
Thanks Michael, it works fine!

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

Thanks,
Phil
 

Similar threads

Top