Link to home
Start Free TrialLog in
Avatar of mlozen
mlozenFlag for United States of America

asked on

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

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?
Avatar of David Lee
David Lee
Flag of United States of America image

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
        Item.Save
    End If
End Sub

Open in new window

Avatar of mlozen

ASKER

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!
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
Avatar of mlozen

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mlozen

ASKER

BlueDevilFan,

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!
You're welcome.  Sorry I couldn't help  :-(