Solved

Delete from Outlook subject line

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Check out this infographic on what you need to make a good email signature that will work perfectly for your organization.
Find out what you should include to make the best professional email signature for your organization.
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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

867 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

22 Experts available now in Live!

Get 1:1 Help Now