Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Auto date on new mail message

Posted on 2007-08-04
7
Medium Priority
?
328 Views
Last Modified: 2013-11-05
I am trying to find out a method of automatically inserting the date (20070804-) in the subject line of a new outlook 2003 mail message.  On clicking "New Maiil Message" it should insert todays date (dynamically) in the subject line.  Ideally the format should be as per our IM plan YYYY/MM/DD (year/month/day).
0
Comment
Question by:davebain216
  • 3
5 Comments
 
LVL 28

Expert Comment

by:peakpeak
ID: 19630405
The mail server automatically dates the messages, why would you want this as well?
Create a rule that performs a user defined action on sending, write a VB script that does what you want.
0
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 19631536
Hi, davebain216.

The code below does what you've described.  Follow these instructions to use it.

1.  Start Outlook
2.  Click Tools->Macro->Visual Basic Editor.
3.  If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession.
4.  Copy the code and paste it into the right-hand pane of the VB Editor window.
5.  Edit the code as necessary.  I've placed comments where things need to change.
6.  Click the diskette icon on the toolbar to save the changes.
7.  Close the VB Editor.
8.  Click Tools->Macro->Security.
9.  Set the Security Level to Medium.
10.  Close Outlook.
11.  Start Outlook.
12.  Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.


Public WithEvents olkInspectors As Outlook.Inspectors

Private Sub Application_Quit()
    Set olkInspectors = Nothing
End Sub

Private Sub Application_Startup()
    Set olkInspectors = Application.Inspectors
End Sub

Private Sub olkInspectors_NewInspector(ByVal Inspector As Inspector)
    Dim olkItem As Object
    Set olkItem = Inspector.CurrentItem
    If olkItem.Class = olMail Then
        If olkItem.Sent = False Then
            'Change the date format as needed.  You can add additional text to if desired.
            Inspector.CurrentItem.Subject = Format(Date, "YYYY/MM/DD")
        End If
    End If
    Set olkItem = Nothing
End Sub
0
 

Expert Comment

by:Scudboy
ID: 19747142
BlueDevilFan,

I ran across this thread because I am trying to accomplish the same concept to enforce new email standards. The code works great, but I would like to make one change though and I can't figure out how to do it.... How can I make it so the macro only auto inserts the subject on new emails only? The macro as it is right now erases the subject when you reply or forward a message.

Thanks!
0
 
LVL 76

Expert Comment

by:David Lee
ID: 19749843
Hi, Scudboy.

Unfortunately, there is no message property that explicitly distinguishes a new message from a reply or forward.  Both new messages and replies/forwards represent unsent messages, so most of the properties are set the same.  We have to look elsewhere.  The Body property seems like it might distinguish a new message, new messages would be blank, but if the sender is using stationery or a signature, then that test fails.  The best test I can think of is to see if the Subject field is blank.  Of course some people send messages with blank subject lines, so it isn't a perfect test, but it's as close as I think we can get.  Try the revised module below.

Private Sub olkInspectors_NewInspector(ByVal Inspector As Inspector)
    Dim olkItem As Object
    Set olkItem = Inspector.CurrentItem
    If olkItem.Class = olMail Then
        If olkItem.Sent = False Then
            If olkItem.Subject = "" Then
                'Change the date format as needed.  You can add additional text to if desired.
                Inspector.CurrentItem.Subject = Format(Date, "YYYY/MM/DD")
            End If
        End If
    End If
    Set olkItem = Nothing
End Sub
0
 
LVL 76

Expert Comment

by:David Lee
ID: 20518678
Is there anything else I can do to help with this question?
0

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Question has a verified solution.

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

There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
Upgrading from older Exchange server to the latest Exchange server can be tiresome, error-prone and risky, without being a seasoned exchange server administrators. It can become even problematic if you're an organization that runs on tight timeline…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
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.
Suggested Courses
Course of the Month10 days, 10 hours left to enroll

572 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