Assign Categories to Mail via Macro

K

KdBrown

I am looking for a way to assign categories to emails
through a macro. I can currently select several emails in
my inbox, then right click and select categories, then
select the category I want, but what I would like to do is
create a macro which I can place in a toolbar. When I
select items in my inbox, I would then go to the toolbar,
and select the correct button to assign them to the
appropriate category.

Can this be done?

Thanks,
KdBrown
 
K

Ken Slovak - [MVP - Outlook]

Yes. For a macro you'd use Application.ActiveExplorer to get the
current folder. The Selection collection of that Explorer has all your
selected items. So the body of the code would look something like
this:

Dim oSel As Outlook.Selection
Dim oMail As Outlook.Mailitem

Set oSel = Application.ActiveExplorer.Selection
For Each oMail In oSel
oMail.Categories = "my category"
oMail.Save
Next
 
G

Guest

Ken,

Thanks, that worked great. I had been searching high and
low for two weeks for that.

KdBrown
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top