How can I change the subject of messages on an Exchange server automatically?

5,578

Edit: Adding client side subject transform example, per the question not having answer to the Transport or an MTA.

VBA Macro in Outlook

You can write advanced mail handling rules with VBA Macros in Outlook. The important thing to remember is that these rules will only run on your client, and if your client is offline (using your phone) will not execute. They may also vary in usability to the wims of your organizations security posture. If you have the access you may need to alter the Macro security level for Outlook.

  • Access the Visual Basic editor with Alt + F11.
  • Double click ThisOutlookSession

Then add the relevant VB script to alter your subject as your needs dictate.

Sub ChangeSubject()

Dim subjApp As Outlook.Application
Dim sItem As Object

Set subjApp = CreateObject("Outlook.Application")
Set mail = subjApp.ActiveExplorer.CurrentFolder

For Each sItem In mail.Items
  sItem.Subject = "New Subject"
  Item.Save
  Next sItem

End Sub
  • Create a rule in Outlook to call your macro on the conditions you desire.

Transport Rules/MTA

A better path would be to do this in Exchange natively if you have access to control your transport rules or MTA settings. Depending on the version of Exchange, with Transport rules on the HUB exchange role. MSExchange.org has a good example of using tranport rules from Exchange 2007.

Putting an MTA in front of Exchange can also provide this functionality, and I've used Postfix in the past quite well. You may realize other benefits from doing so (Spam Filtering), but it shouldn't be explicitly necessary for you in this case.

Share:
5,578

Related videos on Youtube

Chris R
Author by

Chris R

Updated on September 18, 2022

Comments

  • Chris R
    Chris R over 1 year

    I want to do something more than just normal mail -> folder rules; I want to put a layer in front of my exchange server that lets me, for example, rewrite subjects into a more readable form.

    I get automated messages whose subject format makes them almost useless. Changing the emitting software is not going to happen, so I need to do something client side.

    I'm interested in anything that would allow me to do this, either on a mac, or on an older linux distro. Preferably the latter, and preferably in a way that I can turn on and forget about.

  • Chris R
    Chris R over 12 years
    My problem is that I'm "behind" Exchange here; I have only client level access to it. So, I can only do the things that an MUA can do, not an MTA.
  • Alex
    Alex almost 9 years
    @krondor Same problem here. Though my MTA can do anything I ask her to; I just need the rule to apply only to me. Is this possible?
  • krondor
    krondor almost 8 years
    Apologies for the delay, I assumed you had MTA access. I've added VBA macro guides, there are a few other ways as well. You may want to read more on macros and security though, as they can open yourself to other problems.