Solved

Delete from Outlook subject line

Posted on 2013-11-06
2
379 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Large Outlook files lead to various unwanted errors and corruption issues. Furthermore, large outlook files can also make Outlook take longer to start-up, search, navigate, and shut-down. So, In this article, i will discuss a method to make your Out…
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…
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 https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

630 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