From: notme on
Hi everyone,
I need to set automatically a category to alll email in a IMAP folder. (and
for every new incoming email in this folder)
I've found this code in VBA but it give a category only to the selected
email when the macro is launch.

Sub essai()

Dim MonApply As Outlook.Application
Dim Expl As Explorer
Dim myNameSpace As NameSpace
Dim myFolder As MAPIFolder
Dim myItems As Items
Dim xi As Integer

'object instance
Set MonApply = Outlook.Application 'Application Outlook

'Expl is current folder
Set Expl = ActiveExplorer
'give you all datas embedded
Set myNameSpace = MonApply.GetNamespace("MAPI")

'retreive ID folder to get all messages
Set myFolder =
myNameSpace.GetFolderFromID(Expl.CurrentFolder.EntryID)

'myItems is all items in this folder
Set myItems = myFolder.Items

For xi = 1 To myItems.Count
'this loop should give a category named as the folder name to all
items in folder
myItems.Item(xi).Categories = myFolder.Name

Next xi

End Sub