Outlook 2002:  Remove Private Sensitivity for All Messages Moved Into Specific Folder

Posted on 2009-02-20
Last Modified: 2012-06-27
Outlook 2002  / Exchange 2003
I'm a novice VBA type, and would really appreciate any direction you can offer.
Is there a way to automatically change individual message sensitivity from Private to Normal as the messages are moved into a specific folder?  Or maybe a way to default the sensitivity level on the entire folder as Normal?
Question by:mlozen
    LVL 76

    Expert Comment

    by:David Lee
    Hi, mlozen.

    The code below will do this.  It works on items in the Inbox, but can be modified to work on any folder.  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 WithEvents olkFolder As Outlook.Items
    Private Sub Application_Quit()
        Set olkFolder = Nothing
    End Sub
    Private Sub Application_Startup()
        'Change the folder on the next line'
        Set olkFolder = Session.GetDefaultFolder(olFolderInbox).Items
    End Sub
    Private Sub olkFolder_ItemAdd(ByVal Item As Object)
        If Item.Class = olMail Then
            Item.Sensitivity = olNormal
        End If
    End Sub

    Open in new window


    Author Comment

    I really appreciate your help, and I think I'm almost there, but I'm running into one problem.  When I run the macro, I get a Type Mismatch error on this line of code:

        Set olkFolder = Session.GetDefaultFolder("Mailbox - User Name\Inbox\Folder Name").Items

    It's probably the way that I defined the folder name, but every variation I try results in the same error.  Sorry to make you deal with such an amateur, but if you could offer any insight into what I'm doing wrong in defining the folder name, I'd appreciate it.

    Thanks much!
    LVL 76

    Expert Comment

    by:David Lee
    GetDefaultFolder takes a numeric parameter indicating which of Outlook's build-in folders it should retrieve.  It can't handle a string with a name.  To get a folder under the Inbox, use something like this:

        Set olkFolder = Session.GetDefaultFolder(olFolderInbox).Folders("Folder Name").Items

    Author Comment

    Great!  That addressed my folder issue.  Now, though, when the code runs, I receive a new error:

    Run-time error  '-2147024809 (80070057)'
    The sensitivity of this Private message cannot be changed.  Could not complete the operation.  One or more parameter values are not valid.

    Debug takes me to this line of code:  Item.Sensitivity = olNormal
    LVL 76

    Accepted Solution

    I've never seen this documented anywhere, it's certainly not mentioned in the description of the Sensitivity property, but apparently Outlook doesn't allow changes to the sensitivity setting of received items.  I did find this explanation in a Microsoft page describing the effects of a setting of "private" for sensitivity

        The recipient cannot change the sensitivity setting ...

    If Outlook won't allow a recipient to change the setting from the GUI, then it's not going to be possible from code either.  Apologies.  I'd never encountered this before and didn't see any restrictions on setting sensitivity in the documentation.

    Author Comment


    I was afraid that would be the case.  I really appreciate all the work you put into this.  I'll look for another solution.

    Thanks again!
    LVL 76

    Expert Comment

    by:David Lee
    You're welcome.  Sorry I couldn't help  :-(  

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
    Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    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…

    728 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