Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Delete from Outlook subject line

Posted on 2013-11-06
2
Medium Priority
?
389 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 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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…
Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
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…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

886 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