[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


Special option to auto populate subject line in Outlook 2003

Posted on 2009-04-16
Medium Priority
Last Modified: 2012-05-06
We received a request for a feature in Outlook we have never seen before. Look at the request below and see if there is a feature, 3rd party software or a work around we are unaware of:


With respect to the concept of being able to identify e-mails that are attorney-client privileged, business records, or non-business records, perhaps we can use some buttons in Outlook that would automatically populate the subject line of new e-mails with intro info like ATTORNEY-CLIENT PRIVILEGE: or BUSINESS RECORD: or PERSONAL: etc.  We did something like this at my old company, after a new document classification system was put in place requiring each document to be labeled as Internal Use Only, Confidential, or Restricted.  Buttons were installed on Outlook that would be clicked to begin an e-mail, replacing the New selection with three or four options to get the message started.  So the subject line would say, for example, CONFIDENTIAL: and then the author would fill in the subject of the message after this text.  

Any help appreciated,
Question by:JohnMac328
  • 4
  • 4
LVL 76

Expert Comment

by:David Lee
ID: 24163617
Hi, John.

Yes, this is possible by developing an Outlook add-in or a bit of scripting.  Add-ins are easier to deploy, but require additional tools and more programming effort.  Scripting is easier to write, but harder to deploy.  Forgetting about the delivery method, the code would add the buttons to the toolbar and handle the button's click event to create the chosen message.  If you want to enforce the text in the subject line, then you'll also need either a custom outlook form for each message type, or add code that checks messages before they are sent and restores the subject line text if it's been changed or removed.  The latter approach is simpler.  I can help with putting a script together that does this.  

Author Comment

ID: 24166991
That sounds like what they want, any help is greatly appreciated.
LVL 76

Expert Comment

by:David Lee
ID: 24172854
The solution comes in two parts.  This is part 1.  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
4.  If not already expanded, expand Modules
5.  Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting Insert > Module.
6.  Copy the code from the Code Snippet box and paste it into the right-hand pane of Outlook's VB Editor window
7.  Edit the code as needed.  I included comments wherever something needs to or can change
8.  Click the diskette icon on the toolbar to save the changes
9.  Close the VB Editor

Sub New_ACP_Msg()
    NewMessage "ACP"
End Sub
Sub New_BR_Msg()
    NewMessage "BR"
End Sub
Sub New_Personal_Msg()
    NewMessage "PERS"
End Sub
Sub New_Confidential_Msg()
    NewMessage "CONF"
End Sub
Sub NewMessage(strMsgType As String)
    Dim olkMsg As Outlook.MailItem
    Set olkMsg = Outlook.Application.CreateItem(olMailItem)
    Select Case strMsgType
        Case "ACP"
            olkMsg.Subject = "ATTORNEY-CLIENT PRIVILEGE: "
        Case "BR"
            olkMsg.Subject = "BUSINESS RECORD: "
        Case "PERS"
            olkMsg.Subject = "PERSONAL: "
            olkMsg.Sensitivity = olPersonal
        Case "CONF"
            olkMsg.Subject = "CONFIDENTIAL: "
            olkMsg.Sensitivity = olConfidential
    End Select
    Set olkMsg = Nothing
End Sub

Open in new window

Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

LVL 76

Accepted Solution

David Lee earned 2000 total points
ID: 24172864
This is part 2.  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 from the Code Snippet box and paste it into the right-hand pane of
5.  Outlook's VB Editor window
6.  Edit the code as needed.  I included comment lines wherever something needs to or can change
7.  Click the diskette icon on the toolbar to save the changes
8.  Close the VB Editor
9.  Click Tools->Macro->Security
10. Set the Security Level to Medium
11. Close Outlook
12. Start Outlook
13. Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run.  Say yes.

Private Sub Application_Startup()
    Dim ofcToolbar As Office.CommandBar, _
        ofcAddButton As Office.CommandBarPopup, _
        ofcBtn1 As Office.CommandBarButton, _
        ofcBtn2 As Office.CommandBarButton, _
        ofcBtn3 As Office.CommandBarButton, _
        ofcBtn4 As Office.CommandBarButton
    Set ofcToolbar = Outlook.Application.ActiveExplorer.CommandBars("Standard")
    Set ofcAddButton = ofcToolbar.Controls.Item(1)
    'Add the first button'
    Set ofcBtn1 = ofcAddButton.Controls.Add(msoControlButton, , , 2)
    With ofcBtn1
        .Style = msoButtonAutomatic
        .Caption = "Attorney-Client Privilege Message"
        .FaceId = 1757
        .OnAction = "New_ACP_Msg"
    End With
    'Add the second button'
    Set ofcBtn2 = ofcAddButton.Controls.Add(msoControlButton, , , 3)
    With ofcBtn2
        .Style = msoButtonAutomatic
        .Caption = "Business Record Message"
        .FaceId = 1757
        .OnAction = "New_BR_Msg"
    End With
    'Add the third button'
    Set ofcBtn3 = ofcAddButton.Controls.Add(msoControlButton, , , 4)
    With ofcBtn3
        .Style = msoButtonAutomatic
        .Caption = "Confidential Message"
        .FaceId = 1757
        .OnAction = "New_Confidential_Msg"
    End With
    'Add the fourth button'
    Set ofcBtn4 = ofcAddButton.Controls.Add(msoControlButton, , , 5)
    With ofcBtn4
        .Style = msoButtonAutomatic
        .Caption = "Private Message"
        .FaceId = 1757
        .OnAction = "New_Personal_Msg"
    End With
    Set ofcToolbar = Nothing
    Set ofcAddButton = Nothing
    Set ofcBtn1 = Nothing
    Set ofcBtn2 = Nothing
    Set ofcBtn3 = Nothing
    Set ofcBtn4 = Nothing
End Sub

Open in new window


Author Comment

ID: 24184197
Almost there, now how do I add the buttons?  When I go to Tools-Customize-Toolbars, under Macros I don't have anything showing.  I did click on enable macros when I restarted Outlook.

Author Comment

ID: 24184224
Sorry, that was me.  Thanks

Author Closing Comment

ID: 31571217
Thanks for the help
LVL 76

Expert Comment

by:David Lee
ID: 24184564
You're welcome.  Glad I could help.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this article I discuss my selections of the Top Four free Outlook OST File Viewers available. Open, view and read even damaged OST files by using these tools. They all provide a clear preview of all data such as emails, notes, tasks, calendars, e…
Take a look at these 6 Outlook Email management tools which can augment the working and performance of Microsoft Outlook to give you a more rewarding emailing experience.
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…
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…
Suggested Courses

834 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