Solved

Delete from Outlook subject line

Posted on 2013-11-06
2
374 Views
Last Modified: 2013-11-07
We are adding a time stamp to the end of all of our email messages so that we can store them in a common operating system folder.  When we respond, we don't want the time stamp in the subject line going out.  What kind of VBA can we write to look for a tag that indicates the time stamp and delete everything to the right of that tag (inclusive)?
0
Comment
Question by:M_Patton
  • 2
2 Comments
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 39629529
Can you define how the timestamp is structured ... i.e. dd mmm yyyy / yymmdd hh:mm or whatever?

Chris
0
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
ID: 39629671
Essentially it will look like:

thisOutlookSession:

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Item.Subject = StripDate(Item.Subject)
End Sub

Open in new window


ANd a normal code module with a function like the following which looks for a date in the form mm-dd-yyyy - NO error checking of day/month to keep it simple for now.

Function StripDate(str As String) As String
Dim regex As Object
Dim colMatches As Object

    Set regex = CreateObject("VBscript.RegExp")
    With regex
        .IgnoreCase = True
'        .Pattern = "[0-9]{1,2} [a-z]{3,10} ([0-9]{2}|[0-9]{4}).*"
        .Pattern = "[0-9]{1,2}-[0-9]{1,2}-([0-9]{2}|[0-9]{4}).*"
    End With
    Set colMatches = regex.Execute(str)
    If colMatches.Count > 0 Then
        StripDate = Trim(regex.Replace(str, ""))
    Else
        StripDate = str
    End If

End Function

Open in new window


Obviously the date / time format can be tweaked as soon as you identify your format.

Chris
0

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

Suggested Solutions

Find out what you should include to make the best professional email signature for your organization.
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
Many of my clients call in with monstrous Gmail overloading issues with Outlook. A quick tip is to turn off the All Mail and Important folders from synching. Here is a quick video I made to show you how to turn off these and other folders in Gmail s…
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 https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

821 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