Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting categories using VBA on a selection does not seem to work in Outlook 2007

Tags:

vba

outlook

I'm trying to set the mail message categories for the current selection. When I run the macro I end up in only a single message being set to the given categorie. I Use the following code (and have also tried to use a do until..loop using the selection.count):

Sub SetSelectionComplete()
    Dim mailMsg As MailItem

    For Each mailMsg In Outlook.Application.ActiveExplorer.Selection
        mailMsg.Categories = "Complete"
    Next

End Sub

Any ideas?

like image 512
Janco Avatar asked Mar 04 '10 08:03

Janco


1 Answers

Save the mailMsg item each time, like this:

Sub SetSelectionComplete()
    Dim mailMsg As MailItem
    For Each mailMsg In Outlook.Application.ActiveExplorer.Selection
        mailMsg.Categories = "Complete"
        mailMsg.Save
    Next
End Sub
like image 142
Todd Main Avatar answered Oct 01 '22 06:10

Todd Main