Change the category of a mail item usinb VB

C

CGF

Hello all,
I'm trying to change the Categories in VB, but for some reason it is not
working. My situation is this: In the Inbox folder, I select some mail
items and run the following code:

Sub DefineCategories(CategoryStr As String)
Dim ItemInt As Integer

For ItemInt = 1 To
Application.ActiveExplorer.Selection.Count
Application.ActiveExplorer.Selection(ItemInt).Categories =
CategoryStr
Application.ActiveExplorer.Selection(ItemInt).Save
Next ItemInt
End Sub

But with this code, nothing happens. Could anyone help me with this ?
 
M

Michael Bauer

Am Fri, 02 Jun 2006 06:32:49 -0700 schrieb CGF:

If that code is within Outlook then there seems to be no error. Are sure
it´s running at all? You could set a breakpoint (F9) into the For... line
e.g. and watch whether or not the execution stops there. Then go through it
step by step with F8 and see what happens.
 
C

CGF

Yes, I'm sure it is working. I have already tried to do as you mentioned
(set breakpoint then F8). I had this code running OK on Outlook 2000
once, but I was dummy not backing it up, but I remember the code was
sothing like I wrote in the beginning. Now I'm using Outlook 2003 and
want to have the same feature. Perhaps there is a difference between
2000 and 2003.
 
M

Michael Bauer

Am Mon, 05 Jun 2006 10:27:19 -0700 schrieb CGF:

Weird, it really doesn´t work. But with a little modification it does:

Sub DefineCategories(CategoryStr As String)
Dim ItemInt As Integer
Dim obj As Object

For ItemInt = 1 To Application.ActiveExplorer.Selection.Count
Set obj = Application.ActiveExplorer.Selection(ItemInt)
obj.Categories = CategoryStr
obj.Save
Next ItemInt
End Sub
 

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