removing category for incoming emails

  • Thread starter Thread starter Alexander Weinstock
  • Start date Start date
A

Alexander Weinstock

I found an advice from Sue Mosher for removing categories for outgoing
emails earlier in this group:
Put this code in the
ThisOutlookSession module and make sure macro security isn't set to High
unless you digitally sign the project:

Private Sub Application_ItemSend _
(ByVal Item As Object, Cancel As Boolean)
Item.Categories = ""
End Sub

Can anyone suggest something similar for removing categories for
*incoming* email?

Thanks
Alexander
 
See http://www.outlookcode.com/d/code/zaphtml.htm for a couple of different
ways of working with incoming messages, both with a rule and with the
MAPIFolder.Items.ItemAdd event to monitor the Inbox. The basic code is the
same (refined version):

If Item.Categories <> "" Then
Item.Categories = ""
Item.Save
End IF

I'm curious, though. Why would you care so much about the rare message that
arrives with a category set?


--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Thanks, Sue -- just found that link in the earlier thread before receiving
your message.

I tried to put the following code to VbaProject.OTM.ThisOutlookSession, but
the code is never run (judging by a breakpoint I set on the first line --
and by the categories remaining for incoming mail). Outlook 2003. Doing
something wrong?

Sub RemoveCategories(objMsg As Outlook.MailItem)
If objMsg.Categories <> "" Then
objMsg.Categories = ""
objMsg.Save
End If
End Sub

Another code that still does not seem to work is:
Option Explicit

Private WithEvents olInboxItems As Items

Private Sub Application_Startup()
Dim objNS As NameSpace
Set objNS = Application.GetNamespace("MAPI")
' instantiate objects declared WithEvents
Set olInboxItems = objNS.GetDefaultFolder(olFolderInbox).Items
Set objNS = Nothing
End Sub

Private Sub olInboxItems_ItemAdd(ByVal objMsg As Object)
If objMsg.Categories <> "" Then
objMsg.Categories = ""
objMsg.Save
End If
End Sub

I have the following Security settings:
(Tools>Options>SecurityZoneSettings>Internet zone; Custom Level there)
Initialize and script ActiveX controls not marked as safe: Enable
Run ActiveX controls and plugins: Enable
Script ActiveX controls marked safe for scripting: Enable
Scripting>Active Scripting: Enable

I'm curious, though. Why would you care so much about the rare message that
arrives with a category set?
I'm just not the only advanced user in the office :) Others use categories
as well, and there's no shared category set as different people consider the
same email message from different perspectives.

Alexander
 
Check your macro security under Tools | Macro | Security.

Your RemoveCategories procedure is suitable for running from a rule with a
'run a script' action. Use no conditions, so that it runs against all
messages.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Back
Top