Solved

Delete from Outlook subject line

Posted on 2013-11-06
2
368 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Create high volume marketing opportunities using email signatures with these top 10 DOs and DON'Ts of email signature marketing.
Resolve DNS query failed errors for Exchange
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

708 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now