Special option to auto populate subject line in Outlook 2003

Posted on 2009-04-16
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
    LVL 76

    Expert Comment

    by:David Lee
    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

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

    Expert Comment

    by:David Lee
    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

    LVL 76

    Accepted Solution

    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

    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

    Sorry, that was me.  Thanks

    Author Closing Comment

    Thanks for the help
    LVL 76

    Expert Comment

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

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Find out how to use dynamic social media in email signatures with this top 10 DOs & DON’Ts.
    Outlook Free & Paid Tools
    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…

    760 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

    11 Experts available now in Live!

    Get 1:1 Help Now