Outlook 2010 VBA to remove delete contents in subject line

Posted on 2011-09-14
Last Modified: 2012-11-19
I am trying to run a Outlook rule that will run a script when receiving messages from a particular  email address.  I wan the script to delete the contents of the subject line.  Can someone help me with a script because I have never worked with VBA.  
Question by:beta2028
  • 3
  • 3
LVL 14

Expert Comment

by:Alexei Kuznetsov
ID: 36538338
Something like this:

Sub ClearSubject(Item As Outlook.MailItem)
    Item.Subject = ""
End Sub

Open in new window


Author Comment

ID: 36538945
That didn't work.  I added this to the ThisOutlookSession and then saved the code.  Then ran the script as a rule and it did not clear the subject.  I even tried to run the rule manually and it didn't clear it either.
LVL 14

Expert Comment

by:Alexei Kuznetsov
ID: 36541153
Believe me it works. Looks like you have macro security enabled.
VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

LVL 14

Expert Comment

by:Alexei Kuznetsov
ID: 36541155
Or you just misconfigured your rule.

Accepted Solution

beta2028 earned 0 total points
ID: 36542699
You are correct it was the Macro security.  No wonder I couldn't get any scripts to work.  One last question.  If the subject is Ticket #xxx-xxxxxxx how do I take the Ticket # out of the subject and keep the numbers?  Thanks in advance and getting this to work for me.  

Author Closing Comment

ID: 38612247
Issue resolved

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Library not Registered 16 63
Outlook importing calendar entries 6 80
Outlook 2016 18 49
Outlook 2012 VBA: Object missing 14 32
Is your Office 365 signature not working the way you want it to? Are signature updates taking up too much of your time? Let's run through the most common problems that an IT administrator can encounter when dealing with Office 365 email signatures.
MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit If you want to manage em…

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question