Code to amend subject lines in a public outlook folder ...

  • Thread starter Thread starter Rob Keel
  • Start date Start date
R

Rob Keel

Hi,

Can anyone offer a solution to add a defined number of characters to
all email subject fields stored in a public outlook folder please?

ie ... i have a folder full of emails that begin with a number. From
day 1 (due to no forward planning) the subject line of the first email
stored began with "1 XXXXXXXXXXX" ... now 6 months later we are up to
12000 odd and to aid sorting I would like to add "0000" to the
beginning of all subject fields. So 1<space><space>XXXXXXXX becomes
"00001 XXXXXXXXXXX"

Many thanks,

Rob.
 
This should do it (run with the folder containing the items active in Outlook):

Dim objFolder As Outlook.MAPIFolder
Dim objItems As Outlook.Items
Dim objItem As Outlook.MailItem

'Work with the current folder only
Set objFolder = ActiveExplorer.CurrentFolder
Set objItems = objFolder.Items
For Each objItem In objItems
objItem.Subject = "0000" & objItem.Subject
objItem.Save
Next

Set objItem = Nothing
Set objItems = Nothing
Set objFolder = Nothing
 
Back
Top