Strip Text from Subject Line

Status
Not open for further replies.

Phillip

Member
Outlook version
Outlook 2007
Email Account
POP3
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
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
 

Phillip

Member
Outlook version
Outlook 2007
Email Account
POP3
Thanks Michael, it works fine!

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

Thanks,
Phil
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
J HELP- Rule to auto strip prepend from external emails Using Outlook 0
D VBA Code to strip Subject Line when replying or forwarding Using Outlook 3
P Forwarding emails issue with special characters replacing text body Using Outlook 1
J Autoreply email recieved from specific sender after deleting some text from body. Using Outlook 0
O Outlook tasks - Add text column with multiple lines Using Outlook 3
S Body text of Email from invite date/time Outlook VBA and Custom Forms 7
T Why does outlook 2010 convert only some forum notifications to plain text? Using Outlook 0
B VBA to convert email to task, insert text of email in task notes, and attach copy of original email Outlook VBA and Custom Forms 4
J Outlook 2013 Change color of text in data fields of contacts in Outlook 2013? Using Outlook 10
V Limiting text length in free text field Outlook VBA and Custom Forms 2
Jennifer Murphy Ctrl+Tab sometimes will not move through text a word at a time Using Outlook 1
B Add Prefix text to Subject Line Using Outlook 1
Z Add text to auto-forwarded e-mail Outlook VBA and Custom Forms 4
S Change VBA script to send HTML email instead of text Outlook VBA and Custom Forms 3
M VBA to auto forward message with new subject and body text Outlook VBA and Custom Forms 8
T Missing text in e-mail message after "(Please keep confidential)" Using Outlook 3
S Outlook to check for specific text Outlook VBA and Custom Forms 3
A Read and Write to Text File Outlook VBA and Custom Forms 1
J Program Checkbox that will activate a text box in a Outlook fallible form. Outlook VBA and Custom Forms 1
N How to remove signature formatting from Text in Word (accidentally taken from Outlook) Using Outlook 0
B Paste formatted text (bold, underlined and in quotes) Outlook VBA and Custom Forms 1
J Remove text to Clean Up Outlook VBA and Custom Forms 1
O Macro - paste as plain text Outlook VBA and Custom Forms 2
N Is there an Outlook tool to normalize text for entries that are in ALL CAPS? Using Outlook 2
e_a_g_l_e_p_i Is there a way to add something that is in the "Format Text" tab to the "basic Text" on the message tab Using Outlook 1
D Remove text in subject using VBA Outlook VBA and Custom Forms 4
D Body text of email disappears when I scan an attachment from printer to email Using Outlook 1
S Outlook 2007: Address Cards allow entering text! Why? Using Outlook 3
S View Appointment in Text Wrap in Outlook 2007 Month Calendar View Using Outlook 0
RangerRick Text Extraction from forwarded messages external Exchange Server Administration 1
S Emails Configured As HTML But Sent As Plain Text Using Outlook 13
W Message Text Using Outlook 1
K Update subject based on text in body Outlook VBA and Custom Forms 3
C Transfer Outlook TextBox Text Into Email Body Outlook VBA and Custom Forms 2
J Marco in search of text in subject line Using Outlook 8
Tanja Östrand Outlook 2016 - Create Macro button to add text in Subject Outlook VBA and Custom Forms 1
M attached images not showing in text area Exchange Server Administration 0
Brostin Forward a mail to the address listed in the email text Outlook VBA and Custom Forms 1
P Can't see full text in From and Subject line Using Outlook 1
Stilgar Relsik Create a rule to copy text from an email and paste it in the subject line. Using Outlook 1
S Creating Email - Selecting Pre-Defined Text Using Outlook 2
D Delete selected text from incoming emails Outlook VBA and Custom Forms 25
Diane Poremsky Outlook VBA: Use a Text File to Populate a ListBox New Slipstick.com Articles 0
B Importing Text from Excel to Outlook 2013 Calender Using Outlook 0
B Import Excel Text into Outlook Calender Using Outlook 4
Diane Poremsky Create Task or Appointment and Insert Selected Text New Slipstick.com Articles 0
n2b Accessing Plain Text Draft Without Outlook Using Outlook 3
sneaky30 convert text to date Outlook VBA and Custom Forms 1
C BCM Text Boxes & tabs are too short when downloading to Office 365 BCM (Business Contact Manager) 0
iwshim outlook mail merge -rich text Using Outlook 2

Similar threads

Top