Categories Not Saved

Status
Not open for further replies.
S

spottedmahn

I'm updating my categories in code using the Com objects and I see the

changes in Outlook but when I close and re-open the changes are not there.

More detailed description:

-Outlook 2007 running

-Start my app

-Run code to update the category colors and shortkeys

-I see the color changes in Outlook

-Close my app

-Close Outlook

-Reopen Outlook, changes are gone.
 
It's hard to tell what you're doing without seeing any code, but are you

saving whatever changes you're making?

"spottedmahn" <spottedmahn> wrote in message

news:8214421F-188B-49BD-9C9C-7AF00E4785A7@microsoft.com...
> I'm updating my categories in code using the Com objects and I see the
> changes in Outlook but when I close and re-open the changes are not there.

> More detailed description:
> -Outlook 2007 running
> -Start my app
> -Run code to update the category colors and shortkeys
> -I see the color changes in Outlook
> -Close my app
> -Close Outlook
> -Reopen Outlook, changes are gone.
 
Hi Ken, thanks for the response.

How do I save the changes?

Here is most of the code... please let me know if this is not enough.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Outlook = Microsoft.Office.Interop.Outlook;

namespace OutlookCategoryHelper

{

public class OutlookCategoriesHelper

{

string OutlookNameSpace = "MAPI";

Outlook._Application olApp;

Outlook._NameSpace olNS;

public OutlookCategoriesHelper(Outlook.ApplicationClass AppIn)

{

this.olApp = AppIn;

this.olNS = olApp.GetNamespace(this.OutlookNameSpace);

}

//todo maybe need to create excel program with drop downs,

//copy paste to a tab delimited, lookup enums by name

string CatInvestAndBankingName = "Investments and Banking";

Outlook.OlCategoryColor CatInvestAndBankingColor =

Outlook.OlCategoryColor.olCategoryColorOlive;

Outlook.OlCategoryShortcutKey CatInvestAndBankingKey =

Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyNone;

string CatSifCloseParnersName = "SIF - Close Partners";

Outlook.OlCategoryColor CatSifCloseParnersColor =

Outlook.OlCategoryColor.olCategoryColorSteel;

Outlook.OlCategoryShortcutKey CatSifCloseParnersKey =

Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyNone;

string CatSifFrsaUsisName = "SIF - FRSA USIS";

Outlook.OlCategoryColor CatSifFrsaUsisColor =

Outlook.OlCategoryColor.olCategoryColorBlue;

Outlook.OlCategoryShortcutKey CatSifFrsaUsisKey =

Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyNone;

string CatSifMembersName = "SIF - Members";

Outlook.OlCategoryColor CatSifMemberColor =

Outlook.OlCategoryColor.olCategoryColorRed;

Outlook.OlCategoryShortcutKey CatSifMemberKey =

Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyCtrlF2;

string CatSifVendorsName = "SIF - Vendor";

Outlook.OlCategoryColor CatSifVendorsColor =

Outlook.OlCategoryColor.olCategoryColorOrange;

Outlook.OlCategoryShortcutKey CatSifVendorsKey =

Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyNone;

string CatTech3rdPartyName = "Tech - 3rd Party Rpting";

Outlook.OlCategoryColor CatTech3rdPartyColor =

Outlook.OlCategoryColor.olCategoryColorMaroon;

Outlook.OlCategoryShortcutKey CatTech3rdPartyKey =

Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyNone;

string CatTechDevName = "Tech - Dev";

Outlook.OlCategoryColor CatTechDevColor =

Outlook.OlCategoryColor.olCategoryColorGreen;

Outlook.OlCategoryShortcutKey CatTechDevKey =

Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyNone;

string CatTechSuportName = "Tech - Support";

Outlook.OlCategoryColor CatTechSupportColor =

Outlook.OlCategoryColor.olCategoryColorYellow;

Outlook.OlCategoryShortcutKey CatTechSupportKey =

Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyNone;

public List<OutlookCategory> SifCategories

{

get

{

List<OutlookCategory> Results = new List<OutlookCategory>();

string Name;

Outlook.OlCategoryColor Color;

Outlook.OlCategoryShortcutKey Key;

OutlookCategory Cat;

//Investment and Banking

Name = this.CatInvestAndBankingName;

Color = this.CatInvestAndBankingColor;

Key = this.CatInvestAndBankingKey;

Cat = CreateNewOutlookCategory(Name, Color, Key);

Results.Add(Cat);

//SIF - Close Partners

Name = this.CatSifCloseParnersName;

Color = this.CatSifCloseParnersColor;

Key = this.CatSifCloseParnersKey;

Cat = CreateNewOutlookCategory(Name, Color, Key);

Results.Add(Cat);

//SIF - Members

Name = this.CatSifMembersName;

Color = this.CatSifMemberColor;

Key = this.CatSifMemberKey;

Cat = CreateNewOutlookCategory(Name, Color, Key);

Results.Add(Cat);

//SIF - FRSA USIS

Name = this.CatSifFrsaUsisName;

Color = this.CatSifFrsaUsisColor;

Key = this.CatSifFrsaUsisKey;

Cat = CreateNewOutlookCategory(Name, Color, Key);

Results.Add(Cat);

//SIF - Vendors

Name = this.CatSifVendorsName;

Color = this.CatSifVendorsColor;

Key = this.CatSifVendorsKey;

Cat = CreateNewOutlookCategory(Name, Color, Key);

Results.Add(Cat);

//Tech - 3rd Party Reporting

Name = this.CatTech3rdPartyName;

Color = this.CatTech3rdPartyColor;

Key = this.CatTech3rdPartyKey;

Cat = CreateNewOutlookCategory(Name, Color, Key);

Results.Add(Cat);

//Tech - Support

Name = this.CatTechSuportName;

Color = this.CatTechSupportColor;

Key = this.CatTechSupportKey;

Cat = CreateNewOutlookCategory(Name, Color, Key);

Results.Add(Cat);

//Tech - Dev

Name = this.CatTechDevName;

Color = this.CatTechDevColor;

Key = this.CatTechDevKey;

Cat = CreateNewOutlookCategory(Name, Color, Key);

Results.Add(Cat);

//blank

//

//Color = this.Cat;

//Key = this.Cat;

//Name = this.Cat;

//Cat = CreateNewOutlookCategory(Name, Color, Key);

//Results.Add(Cat);

return Results;

}

}

private OutlookCategory CreateNewOutlookCategory(string NameIn,

Outlook.OlCategoryColor olCategoryColorIn, Outlook.OlCategoryShortcutKey

olCategoryShortcutKeyIn)

{

OutlookCategory Result = new OutlookCategory();

Result.Color = olCategoryColorIn;

Result.ShortcutKey = olCategoryShortcutKeyIn;

Result.Name = NameIn;

return Result;

}

public IEnumerable<Outlook.Category> CategoriesList

{

get

{

Outlook.Categories Cats = this.olNS.Categories;

//foreach (Outlook.Category item in Cats)

//{

//}

IEnumerable<Outlook.Category> Results =

Cats.Cast<Outlook.Category>();

//List<Outlook.Category> ResultsT = Results.ToList();

return Results;

}

}

public void CreateOrUpdateSifCategories()

{

foreach (OutlookCategory Cat in this.SifCategories)

{

CreateOrUpdateSifCategory(Cat);

}

}

private void CreateOrUpdateSifCategory(OutlookCategory Cat)

{

var Query = this.CategoriesList.Where(x =
x.Name.Equals(Cat.Name));

if (Query.Any())

{

Outlook._Category OCat = Query.Take(1).Single();

OCat.Color = Cat.Color;

OCat.ShortcutKey = Cat.ShortcutKey;

}

else

{

this.olNS.Categories.Add(Cat.Name, Cat.Color,

Cat.ShortcutKey);

}

}

}

}

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using Outlook = Microsoft.Office.Interop.Outlook;

namespace OutlookCategoryHelper

{

public class OutlookCategory

{

public string Name { get; set; }

public Outlook.OlCategoryColor Color { get; set; }

public Outlook.OlCategoryShortcutKey ShortcutKey { get; set; }

}

}
wrote:


> It's hard to tell what you're doing without seeing any code, but are you
> saving whatever changes you're making?

> >

>

> "spottedmahn" <spottedmahn> wrote in message
> news:8214421F-188B-49BD-9C9C-7AF00E4785A7@microsoft.com...
> > I'm updating my categories in code using the Com objects and I see the
> > changes in Outlook but when I close and re-open the changes are not there.
> > More detailed description:
> > -Outlook 2007 running
> > -Start my app
> > -Run code to update the category colors and shortkeys
> > -I see the color changes in Outlook
> > -Close my app
> > -Close Outlook
> > -Reopen Outlook, changes are gone.


>
 
The line that I see on a brief scan of the code that actually adds a new

category to the Categories collection is this:

this.olNS.Categories.Add(Cat.Name, Cat.Color, Cat.ShortcutKey);

Are you sure this line is actually being executed in your code? Maybe add a

Debug.Writeline() call just before that line to verify it is being hit,

otherwise whatever you do won't persist.

"spottedmahn" <spottedmahn> wrote in message

news:D8B059A4-2615-458A-8A84-A8CF91ABFE47@microsoft.com...
> Hi Ken, thanks for the response.

> How do I save the changes?

> Here is most of the code... please let me know if this is not enough.

> using System;
> using System.Collections.Generic;
> using System.Linq;
> using System.Text;

> using Outlook = Microsoft.Office.Interop.Outlook;

> namespace OutlookCategoryHelper
> {
> public class OutlookCategoriesHelper
> {
> string OutlookNameSpace = "MAPI";

> Outlook._Application olApp;
> Outlook._NameSpace olNS;

> public OutlookCategoriesHelper(Outlook.ApplicationClass AppIn)
> {
> this.olApp = AppIn;
> this.olNS = olApp.GetNamespace(this.OutlookNameSpace);
> }

> //todo maybe need to create excel program with drop downs,
> //copy paste to a tab delimited, lookup enums by name

> string CatInvestAndBankingName = "Investments and Banking";
> Outlook.OlCategoryColor CatInvestAndBankingColor =
> Outlook.OlCategoryColor.olCategoryColorOlive;
> Outlook.OlCategoryShortcutKey CatInvestAndBankingKey =
> Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyNone;

> string CatSifCloseParnersName = "SIF - Close Partners";
> Outlook.OlCategoryColor CatSifCloseParnersColor =
> Outlook.OlCategoryColor.olCategoryColorSteel;
> Outlook.OlCategoryShortcutKey CatSifCloseParnersKey =
> Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyNone;

> string CatSifFrsaUsisName = "SIF - FRSA USIS";
> Outlook.OlCategoryColor CatSifFrsaUsisColor =
> Outlook.OlCategoryColor.olCategoryColorBlue;
> Outlook.OlCategoryShortcutKey CatSifFrsaUsisKey =
> Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyNone;

> string CatSifMembersName = "SIF - Members";
> Outlook.OlCategoryColor CatSifMemberColor =
> Outlook.OlCategoryColor.olCategoryColorRed;
> Outlook.OlCategoryShortcutKey CatSifMemberKey =
> Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyCtrlF2;

> string CatSifVendorsName = "SIF - Vendor";
> Outlook.OlCategoryColor CatSifVendorsColor =
> Outlook.OlCategoryColor.olCategoryColorOrange;
> Outlook.OlCategoryShortcutKey CatSifVendorsKey =
> Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyNone;

> string CatTech3rdPartyName = "Tech - 3rd Party Rpting";
> Outlook.OlCategoryColor CatTech3rdPartyColor =
> Outlook.OlCategoryColor.olCategoryColorMaroon;
> Outlook.OlCategoryShortcutKey CatTech3rdPartyKey =
> Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyNone;

> string CatTechDevName = "Tech - Dev";
> Outlook.OlCategoryColor CatTechDevColor =
> Outlook.OlCategoryColor.olCategoryColorGreen;
> Outlook.OlCategoryShortcutKey CatTechDevKey =
> Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyNone;

> string CatTechSuportName = "Tech - Support";
> Outlook.OlCategoryColor CatTechSupportColor =
> Outlook.OlCategoryColor.olCategoryColorYellow;
> Outlook.OlCategoryShortcutKey CatTechSupportKey =
> Outlook.OlCategoryShortcutKey.olCategoryShortcutKeyNone;

> public List<OutlookCategory> SifCategories
> {
> get
> {
> List<OutlookCategory> Results = new
> List<OutlookCategory>();

> string Name;
> Outlook.OlCategoryColor Color;
> Outlook.OlCategoryShortcutKey Key;
> OutlookCategory Cat;

> //Investment and Banking
> Name = this.CatInvestAndBankingName;
> Color = this.CatInvestAndBankingColor;
> Key = this.CatInvestAndBankingKey;
> Cat = CreateNewOutlookCategory(Name, Color, Key);
> Results.Add(Cat);

> //SIF - Close Partners
> Name = this.CatSifCloseParnersName;
> Color = this.CatSifCloseParnersColor;
> Key = this.CatSifCloseParnersKey;
> Cat = CreateNewOutlookCategory(Name, Color, Key);
> Results.Add(Cat);

> //SIF - Members
> Name = this.CatSifMembersName;
> Color = this.CatSifMemberColor;
> Key = this.CatSifMemberKey;
> Cat = CreateNewOutlookCategory(Name, Color, Key);
> Results.Add(Cat);

> //SIF - FRSA USIS
> Name = this.CatSifFrsaUsisName;
> Color = this.CatSifFrsaUsisColor;
> Key = this.CatSifFrsaUsisKey;
> Cat = CreateNewOutlookCategory(Name, Color, Key);
> Results.Add(Cat);

> //SIF - Vendors
> Name = this.CatSifVendorsName;
> Color = this.CatSifVendorsColor;
> Key = this.CatSifVendorsKey;
> Cat = CreateNewOutlookCategory(Name, Color, Key);
> Results.Add(Cat);

> //Tech - 3rd Party Reporting
> Name = this.CatTech3rdPartyName;
> Color = this.CatTech3rdPartyColor;
> Key = this.CatTech3rdPartyKey;
> Cat = CreateNewOutlookCategory(Name, Color, Key);
> Results.Add(Cat);

> //Tech - Support
> Name = this.CatTechSuportName;
> Color = this.CatTechSupportColor;
> Key = this.CatTechSupportKey;
> Cat = CreateNewOutlookCategory(Name, Color, Key);
> Results.Add(Cat);

> //Tech - Dev
> Name = this.CatTechDevName;
> Color = this.CatTechDevColor;
> Key = this.CatTechDevKey;
> Cat = CreateNewOutlookCategory(Name, Color, Key);
> Results.Add(Cat);

> //blank
> //
> //Color = this.Cat;
> //Key = this.Cat;
> //Name = this.Cat;
> //Cat = CreateNewOutlookCategory(Name, Color, Key);

> //Results.Add(Cat);

> return Results;

> }
> }

> private OutlookCategory CreateNewOutlookCategory(string NameIn,
> Outlook.OlCategoryColor olCategoryColorIn, Outlook.OlCategoryShortcutKey
> olCategoryShortcutKeyIn)
> {
> OutlookCategory Result = new OutlookCategory();

> Result.Color = olCategoryColorIn;
> Result.ShortcutKey = olCategoryShortcutKeyIn;
> Result.Name = NameIn;

> return Result;
> }

> public IEnumerable<Outlook.Category> CategoriesList
> {
> get
> {
> Outlook.Categories Cats = this.olNS.Categories;

> //foreach (Outlook.Category item in Cats)
> //{

> //}

> IEnumerable<Outlook.Category> Results =
> Cats.Cast<Outlook.Category>();

> //List<Outlook.Category> ResultsT = Results.ToList();

> return Results;
> }
> }

> public void CreateOrUpdateSifCategories()
> {
> foreach (OutlookCategory Cat in this.SifCategories)
> {
> CreateOrUpdateSifCategory(Cat);
> }

> }

> private void CreateOrUpdateSifCategory(OutlookCategory Cat)
> {
> var Query = this.CategoriesList.Where(x =
> x.Name.Equals(Cat.Name));

> if (Query.Any())
> {
> Outlook._Category OCat = Query.Take(1).Single();
> OCat.Color = Cat.Color;
> OCat.ShortcutKey = Cat.ShortcutKey;
> }
> else
> {
> this.olNS.Categories.Add(Cat.Name, Cat.Color,
> Cat.ShortcutKey);
> }
> }

> }
> }

> using System;
> using System.Collections.Generic;
> using System.Linq;
> using System.Text;

> using Outlook = Microsoft.Office.Interop.Outlook;

> namespace OutlookCategoryHelper
> {
> public class OutlookCategory
> {
> public string Name { get; set; }
> public Outlook.OlCategoryColor Color { get; set; }
> public Outlook.OlCategoryShortcutKey ShortcutKey { get; set; }
> }
> }
>
 
Hi Ken, thanks again for the response.

Yes the both branches of that if else are being executed. I put a

breakpoint in each of them and stepped thru the code.

Here is a screen shot of what is happening:

http://spottedmahn.spaces.live.com/blog/cns!CF657615B69F016B!407.entry
wrote:


> The line that I see on a brief scan of the code that actually adds a new
> category to the Categories collection is this:

> this.olNS.Categories.Add(Cat.Name, Cat.Color, Cat.ShortcutKey);

> Are you sure this line is actually being executed in your code? Maybe add a
> Debug.Writeline() call just before that line to verify it is being hit,
> otherwise whatever you do won't persist.
>
 
When I get a chance I'll load your code and see what results I get.

"spottedmahn" <spottedmahn> wrote in message

news:C93D1ED2-E1BA-4723-90BB-AD69D38FB6CE@microsoft.com...
> Hi Ken, thanks again for the response.

> Yes the both branches of that if else are being executed. I put a
> breakpoint in each of them and stepped thru the code.

> Here is a screen shot of what is happening:
> http://spottedmahn.spaces.live.com/blog/cns!CF657615B69F016B!407.entry
>
 
Hi all,

we have a similar problem. We are using two vb-scripts, the first one to

delete all existing categories and a second one to "install" our predefined

categories. The two scripts were working since Jan/Feb 2009 with Outlook 2007

SP1. It seems that the scripts for the categories are not working anymore

since installing Office 2007 SP2.

We have the same symptoms:

- Outlook 2007 running

- Run one of our vb-script (delete categories or install categories)

- I see all categories deleted and then all our custom predefined categories

- Close Outlook

- Reopen Outlook

- All changes in categories are gone.

Any idea or solution?

Manfred
wrote:


> When I get a chance I'll load your code and see what results I get.

> >

>

> "spottedmahn" <spottedmahn> wrote in message
> news:C93D1ED2-E1BA-4723-90BB-AD69D38FB6CE@microsoft.com...
> > Hi Ken, thanks again for the response.
> > Yes the both branches of that if else are being executed. I put a
> > breakpoint in each of them and stepped thru the code.
> > Here is a screen shot of what is happening:
> > http://spottedmahn.spaces.live.com/blog/cns!CF657615B69F016B!407.entry
> >


>
 
As I said to the other poster, I can't repro this problem here on a couple

of Outlook 2007 SP2 systems. I plan to test the poster's code when I get a

chance to see what's going on. All I can say is that I have my own addin

code that completely changes the categories list and it continues to work on

SP2.

If I do turn up a but created by SP2 I'll report it to MS, but that won't

help until or if MS fixes the problem.

"Manfred" <Manfred> wrote in message

news:2D23D9C7-3F9C-4AF6-8C17-F851E3C12A04@microsoft.com...
> Hi all,

> we have a similar problem. We are using two vb-scripts, the first one to
> delete all existing categories and a second one to "install" our
> predefined
> categories. The two scripts were working since Jan/Feb 2009 with Outlook
> 2007
> SP1. It seems that the scripts for the categories are not working anymore
> since installing Office 2007 SP2.

> We have the same symptoms:
> - Outlook 2007 running
> - Run one of our vb-script (delete categories or install categories)
> - I see all categories deleted and then all our custom predefined
> categories
> - Close Outlook
> - Reopen Outlook
> - All changes in categories are gone.

> Any idea or solution?

> Manfred
 
Is your default mail account by chance IMAP? That could explain it as IMAP

doesn't support categories. Outlook won't try to write the categories to the

Master Category List until you close it, and that's when they get lost.

Other ideas: you're connected to a mailserver other than Exchange, or you

don't have the permission to write to the default calendar of the mailbox.

Did you test already whether or not you can add categories to the mailbox by

using Outlook's Categorize dialog?

Best regards

Michael Bauer

Am Wed, 24 Jun 2009 10:15:01 -0700 schrieb spottedmahn:


> Hi Ken, thanks again for the response.

> Yes the both branches of that if else are being executed. I put a
> breakpoint in each of them and stepped thru the code.

> Here is a screen shot of what is happening:
> http://spottedmahn.spaces.live.com/blog/cns!CF657615B69F016B!407.entry

> " - " wrote:
>
> > The line that I see on a brief scan of the code that actually adds a new
> > category to the Categories collection is this:
>

>> this.olNS.Categories.Add(Cat.Name, Cat.Color, Cat.ShortcutKey);
>

>> Are you sure this line is actually being executed in your code? Maybe add


a
> > Debug.Writeline() call just before that line to verify it is being hit,
> > otherwise whatever you do won't persist.
> >
 
Good thinking, Michael, I hadn't thought of IMAP or any HTTP based stores

where the PST is just a mirror into that server. None of those would support

persisting categories. Nor would a BCM store unless the BCM database

supported synching up categories.

"Michael Bauer " <mb@mvps.org> wrote in message

news:19d61k9i8yt5n$.1vr7v5u46lygc$.dlg@40tude.net...

> Is your default mail account by chance IMAP? That could explain it as IMAP
> doesn't support categories. Outlook won't try to write the categories to
> the
> Master Category List until you close it, and that's when they get lost.

> Other ideas: you're connected to a mailserver other than Exchange, or you
> don't have the permission to write to the default calendar of the mailbox.

> Did you test already whether or not you can add categories to the mailbox
> by
> using Outlook's Categorize dialog?

> > Best regards
> Michael Bauer

> > >
 
I tested the code and a quickie VBA macro, as well as one of my own addins

that uses VB6, and I cannot reproduce any problem in persisting changes to

the categories list. See the post by Michael Bauer and see if what he says

applies to your situation.

"spottedmahn" <spottedmahn> wrote in message

news:C93D1ED2-E1BA-4723-90BB-AD69D38FB6CE@microsoft.com...
> Hi Ken, thanks again for the response.

> Yes the both branches of that if else are being executed. I put a
> breakpoint in each of them and stepped thru the code.

> Here is a screen shot of what is happening:
> http://spottedmahn.spaces.live.com/blog/cns!CF657615B69F016B!407.entry
>
 
I hope I'm not double posting... I clicked post but the dialog never went away.

No, I don't we are using IMAP but how do I verify? If I look at my account

settings the type is "Exchange" which suspect means MAPI.

I am connecting to an Exchange server.

Are you asking if I can update my calendar? If so, then yes I can modify my

calendar.

Yes, I can add categories using Outlook dialog. To test I added a new

category, assigned it to an email, remoted into our terminal server, opened

Outlook and the email was there with the new category.

Thanks,

Mike D.

"Michael Bauer " wrote:



> Is your default mail account by chance IMAP? That could explain it as IMAP
> doesn't support categories. Outlook won't try to write the categories to the
> Master Category List until you close it, and that's when they get lost.

> Other ideas: you're connected to a mailserver other than Exchange, or you
> don't have the permission to write to the default calendar of the mailbox.

> Did you test already whether or not you can add categories to the mailbox by
> using Outlook's Categorize dialog?

> > Best regards
> Michael Bauer

> > >

> Am Wed, 24 Jun 2009 10:15:01 -0700 schrieb spottedmahn:
>
> > Hi Ken, thanks again for the response.
> > Yes the both branches of that if else are being executed. I put a
> > breakpoint in each of them and stepped thru the code.
> > Here is a screen shot of what is happening:
> > http://spottedmahn.spaces.live.com/blog/cns!CF657615B69F016B!407.entry
> > " - " wrote:
> >
> >> The line that I see on a brief scan of the code that actually adds a new
> >> category to the Categories collection is this:
> >
> >> this.olNS.Categories.Add(Cat.Name, Cat.Color, Cat.ShortcutKey);
> >
> >> Are you sure this line is actually being executed in your code? Maybe add

> a
> >> Debug.Writeline() call just before that line to verify it is being hit,
> >> otherwise whatever you do won't persist.
> >>

>
 
Hi Ken, thanks for testing the code.

I have read Michael Bauer's post and posted a reply.

Mike D.
wrote:


> I tested the code and a quickie VBA macro, as well as one of my own addins
> that uses VB6, and I cannot reproduce any problem in persisting changes to
> the categories list. See the post by Michael Bauer and see if what he says
> applies to your situation.

> >

>

> "spottedmahn" <spottedmahn> wrote in message
> news:C93D1ED2-E1BA-4723-90BB-AD69D38FB6CE@microsoft.com...
> > Hi Ken, thanks again for the response.
> > Yes the both branches of that if else are being executed. I put a
> > breakpoint in each of them and stepped thru the code.
> > Here is a screen shot of what is happening:
> > http://spottedmahn.spaces.live.com/blog/cns!CF657615B69F016B!407.entry
> >


>
 
If you use the Outlook dialog to add a category, see if it still exists in

your Master Category List, i.e. the list you see when you click the

Categorize button, after re-starting Outlook.

Best regards

Michael Bauer

Am Mon, 29 Jun 2009 09:52:01 -0700 schrieb spottedmahn:


> I hope I'm not double posting... I clicked post but the dialog never went


away.

> No, I don't we are using IMAP but how do I verify? If I look at my


account
> settings the type is "Exchange" which suspect means MAPI.

> I am connecting to an Exchange server.

> Are you asking if I can update my calendar? If so, then yes I can modify


my
> calendar.

> Yes, I can add categories using Outlook dialog. To test I added a new
> category, assigned it to an email, remoted into our terminal server,


opened
> Outlook and the email was there with the new category.

> Thanks,
> Mike D.

> "Michael Bauer " wrote:
>
>

>
>> Is your default mail account by chance IMAP? That could explain it as


IMAP
> > doesn't support categories. Outlook won't try to write the categories to


the
> > Master Category List until you close it, and that's when they get lost.
>

>> Other ideas: you're connected to a mailserver other than Exchange, or you
> > don't have the permission to write to the default calendar of the


mailbox.
>

>> Did you test already whether or not you can add categories to the mailbox


by
> > using Outlook's Categorize dialog?
>

>> > > Best regards
> > Michael Bauer
>

>> >> >>

>

>
>> Am Wed, 24 Jun 2009 10:15:01 -0700 schrieb spottedmahn:
> >
> >> Hi Ken, thanks again for the response.
> >
>>> Yes the both branches of that if else are being executed. I put a
> >> breakpoint in each of them and stepped thru the code.
> >
>>> Here is a screen shot of what is happening:
> >> http://spottedmahn.spaces.live.com/blog/cns!CF657615B69F016B!407.entry
> >
>>
>>> " - " wrote:
> >
>>>> The line that I see on a brief scan of the code that actually adds a


new
> >>> category to the Categories collection is this:
> >>
>>>> this.olNS.Categories.Add(Cat.Name, Cat.Color, Cat.ShortcutKey);
> >>
>>>> Are you sure this line is actually being executed in your code? Maybe


add
> > a
> >>> Debug.Writeline() call just before that line to verify it is being hit,
> >>> otherwise whatever you do won't persist.
> >>>

> >
 
Yes, I have added a new category via the Outlook dialog, close and reopened

Outlook and the category is there.

"Michael Bauer " wrote:



> If you use the Outlook dialog to add a category, see if it still exists in
> your Master Category List, i.e. the list you see when you click the
> Categorize button, after re-starting Outlook.

> > Best regards
> Michael Bauer

> > >

> Am Mon, 29 Jun 2009 09:52:01 -0700 schrieb spottedmahn:
>
> > I hope I'm not double posting... I clicked post but the dialog never went

> away.
> > No, I don't we are using IMAP but how do I verify? If I look at my

> account
> > settings the type is "Exchange" which suspect means MAPI.
> > I am connecting to an Exchange server.
> > Are you asking if I can update my calendar? If so, then yes I can modify

> my
> > calendar.
> > Yes, I can add categories using Outlook dialog. To test I added a new
> > category, assigned it to an email, remoted into our terminal server,

> opened
> > Outlook and the email was there with the new category.
> > Thanks,
> > Mike D.
> > "Michael Bauer " wrote:
> >
> >
> >
> >> Is your default mail account by chance IMAP? That could explain it as

> IMAP
> >> doesn't support categories. Outlook won't try to write the categories to

> the
> >> Master Category List until you close it, and that's when they get lost.
> >
> >> Other ideas: you're connected to a mailserver other than Exchange, or you
> >> don't have the permission to write to the default calendar of the

> mailbox.
> >
> >> Did you test already whether or not you can add categories to the mailbox

> by
> >> using Outlook's Categorize dialog?
> >
> >> > >> Best regards
> >> Michael Bauer
> >
> >> > >> > >>

> >
> >
> >> Am Wed, 24 Jun 2009 10:15:01 -0700 schrieb spottedmahn:
> >
> >>> Hi Ken, thanks again for the response.
> >>
> >>> Yes the both branches of that if else are being executed. I put a
> >>> breakpoint in each of them and stepped thru the code.
> >>
> >>> Here is a screen shot of what is happening:
> >>> http://spottedmahn.spaces.live.com/blog/cns!CF657615B69F016B!407.entry
> >>
> >>
> >>> " - " wrote:
> >>
> >>>> The line that I see on a brief scan of the code that actually adds a

> new
> >>>> category to the Categories collection is this:
> >>>
> >>>> this.olNS.Categories.Add(Cat.Name, Cat.Color, Cat.ShortcutKey);
> >>>
> >>>> Are you sure this line is actually being executed in your code? Maybe

> add
> >> a
> >>>> Debug.Writeline() call just before that line to verify it is being hit,
> >>>> otherwise whatever you do won't persist.
> >>>
> >>

>
 
Hello Ken,

here is my sample code for deleting existing categories:

Option Explicit

Dim oOutlook : Set oOutlook = CreateObject("Outlook.Application")

Dim oNameSpace : Set oNameSpace = oOutlook.GetNameSpace("MAPI")

Dim theCategories

Dim theCategory

Dim i

Set theCategories = oNameSpace.Categories

For Each theCategory in theCategories

WScript.StdOut.Writeline theCategory.Name & theCategory.CategoryID

Next

For i = 1 to theCategories.Count

theCategories.Remove 1

Next

I have tested this code once again on a machine with office 2007 sp1 and the

categories were deleted correctly.

After installation of sp2 it seems, that the changes (deleting) of

categories are not saved to the exchange store. The code is running and the

categories seem to be deleted, but after closing and starting outlook, all my

categories are back again.

Any idea or solution?

Manfred
wrote:


> As I said to the other poster, I can't repro this problem here on a couple
> of Outlook 2007 SP2 systems. I plan to test the poster's code when I get a
> chance to see what's going on. All I can say is that I have my own addin
> code that completely changes the categories list and it continues to work on
> SP2.

> If I do turn up a but created by SP2 I'll report it to MS, but that won't
> help until or if MS fixes the problem.

> >

>

> "Manfred" <Manfred> wrote in message
> news:2D23D9C7-3F9C-4AF6-8C17-F851E3C12A04@microsoft.com...
> > Hi all,
> > we have a similar problem. We are using two vb-scripts, the first one to
> > delete all existing categories and a second one to "install" our
> > predefined
> > categories. The two scripts were working since Jan/Feb 2009 with Outlook
> > 2007
> > SP1. It seems that the scripts for the categories are not working anymore
> > since installing Office 2007 SP2.
> > We have the same symptoms:
> > - Outlook 2007 running
> > - Run one of our vb-script (delete categories or install categories)
> > - I see all categories deleted and then all our custom predefined
> > categories
> > - Close Outlook
> > - Reopen Outlook
> > - All changes in categories are gone.
> > Any idea or solution?
> > Manfred


>
 
It's obviously related to your other problem, but I can't repro it here on

any of my Outlook 2007 SP2 systems. So it's specific to your computer.

A word of advice, when deleting items from a collection use a count down For

loop, not a count up loop. Otherwise the loop usually ends up deleting or

moving only 1/2 of the items in each pass.

"Manfred" <Manfred> wrote in message

news:B2678AFA-61C0-4672-B450-4C521DDE7228@microsoft.com...
> Hello Ken,

> here is my sample code for deleting existing categories:

> Option Explicit

> Dim oOutlook : Set oOutlook = CreateObject("Outlook.Application")
> Dim oNameSpace : Set oNameSpace = oOutlook.GetNameSpace("MAPI")
> Dim theCategories
> Dim theCategory
> Dim i

> Set theCategories = oNameSpace.Categories

> For Each theCategory in theCategories
> WScript.StdOut.Writeline theCategory.Name & theCategory.CategoryID
> Next

> For i = 1 to theCategories.Count
> theCategories.Remove 1
> Next

> I have tested this code once again on a machine with office 2007 sp1 and
> the
> categories were deleted correctly.

> After installation of sp2 it seems, that the changes (deleting) of
> categories are not saved to the exchange store. The code is running and
> the
> categories seem to be deleted, but after closing and starting outlook, all
> my
> categories are back again.

> Any idea or solution?

> Manfred
 
Hi Ken,

no, this is not a problem with one computer, we have this problem on all

computers.

And it is definitivly reproducable working with SP1 and NOT working with SP2.

The loop was working correctly all the time from Jan 2009 to Jun 2009

(installing SP2), so this is not the problem.

In my opinion this is a problem with saving the changes back to the exchange

mailbox store.

Manfred
wrote:


> It's obviously related to your other problem, but I can't repro it here on
> any of my Outlook 2007 SP2 systems. So it's specific to your computer.

> A word of advice, when deleting items from a collection use a count down For
> loop, not a count up loop. Otherwise the loop usually ends up deleting or
> moving only 1/2 of the items in each pass.

> >

>

> "Manfred" <Manfred> wrote in message
> news:B2678AFA-61C0-4672-B450-4C521DDE7228@microsoft.com...
> > Hello Ken,
> > here is my sample code for deleting existing categories:
> > Option Explicit
> > Dim oOutlook : Set oOutlook = CreateObject("Outlook.Application")
> > Dim oNameSpace : Set oNameSpace = oOutlook.GetNameSpace("MAPI")
> > Dim theCategories
> > Dim theCategory
> > Dim i
> > Set theCategories = oNameSpace.Categories
> > For Each theCategory in theCategories
> > WScript.StdOut.Writeline theCategory.Name & theCategory.CategoryID
> > Next
> > For i = 1 to theCategories.Count
> > theCategories.Remove 1
> > Next
> > I have tested this code once again on a machine with office 2007 sp1 and
> > the
> > categories were deleted correctly.
> > After installation of sp2 it seems, that the changes (deleting) of
> > categories are not saved to the exchange store. The code is running and
> > the
> > categories seem to be deleted, but after closing and starting outlook, all
> > my
> > categories are back again.
> > Any idea or solution?
> > Manfred


>
 
It's obviously not a universal problem since I can't repro it here.

All I can suggest is to open a support case with MS and see what they say.

If it's their bug they will refund or waive the charges for the support

case, if it's not a bug then you pay for the case.

"Manfred" <Manfred> wrote in message

news:2B67B603-6C00-46E3-94D4-18392D08F885@microsoft.com...
> Hi Ken,

> no, this is not a problem with one computer, we have this problem on all
> computers.
> And it is definitivly reproducable working with SP1 and NOT working with
> SP2.

> The loop was working correctly all the time from Jan 2009 to Jun 2009
> (installing SP2), so this is not the problem.

> In my opinion this is a problem with saving the changes back to the
> exchange
> mailbox store.

> Manfred
 
Thanks for all of your input Ken.

I'll open a case with MSFT and post the results.

Regards,

Mike D.
wrote:


> It's obviously not a universal problem since I can't repro it here.

> All I can suggest is to open a support case with MS and see what they say.
> If it's their bug they will refund or waive the charges for the support
> case, if it's not a bug then you pay for the case.

> >

>

> "Manfred" <Manfred> wrote in message
> news:2B67B603-6C00-46E3-94D4-18392D08F885@microsoft.com...
> > Hi Ken,
> > no, this is not a problem with one computer, we have this problem on all
> > computers.
> > And it is definitivly reproducable working with SP1 and NOT working with
> > SP2.
> > The loop was working correctly all the time from Jan 2009 to Jun 2009
> > (installing SP2), so this is not the problem.
> > In my opinion this is a problem with saving the changes back to the
> > exchange
> > mailbox store.
> > Manfred


>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
V VBA Categories unrelated to visible calendar and Visual appointment Categories Outlook VBA and Custom Forms 2
Z Outlook 365 Automatically assign categories to incoming mail in a shared folder Round Robin Outlook VBA and Custom Forms 1
P How to add a column named categories when searching in Outlook Using Outlook 0
S Folder Pane Colour Categories Using Outlook 6
Ken Pascoe Outlook Categories Quick List Using Outlook 0
R Assign Categories "Round Robin" style but in a shared mailbox but on specific emails only Outlook VBA and Custom Forms 8
O Calendar - appointment templates and categories Using Outlook 1
T Increasing the number of items that appear on the Categories list Using Outlook 2
Y Outlook 2013 Stop Outlook from automatically assigning categories to Tasks Using Outlook 0
D Assign categories to outgoing emails Outlook VBA and Custom Forms 0
Z How to show concatenated categories in list task view? Using Outlook 2
D Importing Outlook Categories from another domain (Exchange 2016/Outlook 2016) Using Outlook 4
S Conditional formatting problem with "is not empty" and categories Using Outlook 2
A Outlook macro to create search folder with mail categories as criteria Outlook VBA and Custom Forms 3
P how to remove unwanted PST file default categories assigned to many calendar entries Using Outlook 7
P Import Categories from Outlook 2003 Using Outlook 8
A Outlook reverse categories Outlook VBA and Custom Forms 1
Mark Foley Color Categories on IMAP mail lost when installing new Windows 7 workstation Using Outlook 12
B VBA Macro for assigning multiple Categories to an email in my Inbox Outlook VBA and Custom Forms 1
P Task Categories Using Outlook 2
I categories for outgoing email Outlook VBA and Custom Forms 7
S Appointment-Cannot set Categories because ConversationID is not set Outlook VBA and Custom Forms 1
M Using conditional formatting on a shared calendar with categories Using Outlook 6
S Appointment colour categories disappear Using Outlook 4
Z Outlook.com Contact categories Using Outlook 8
A Are categories still recommended for creating local distribution lists? Using Outlook 3
Diane Poremsky Using Categories for Dynamic Distribution Lists Using Outlook 0
Diane Poremsky Printing Calendars with Color Categories Using Outlook 0
avant-guvnor Outlook 2016 and views, categories etc. Using Outlook 3
T categories in Outlook 2016 Using Outlook 0
makinmyway How to Easily/Quickly Ungroup by Categories Using Outlook 1
C Printing tasks with multiple categories Using Outlook 5
Mark Foley Where are Outlook categories save for IMAP? Using Outlook 12
M Trouble using keyboard shortcut for color categories in Outlook 2016 Using Outlook 3
T Outlook 2007 adding categories Using Outlook 15
E Outlook 2013 is stripping out categories on sent meeting invites Using Outlook 0
Karlski Deselecting categories often takes 3+ attempts Using Outlook 3
A Keep color categories when saving vCards Using Outlook 1
Diane Poremsky How to Upgrade to Color Categories Using Outlook 0
K Missing Categories & Colors Using Outlook 5
Diane Poremsky Create a list of color categories and merge or restore the list using VBA Using Outlook 0
V Outlook 2010 – Send email based on categories Using Outlook 2
W Sync categories between Exchange and 2007 Exchange Server Administration 1
C Adding Categories when Composing Email Using Outlook 1
D Error in the Categories view Using Outlook 2
J Lost email categories when migrating from Office 2010 to Office 2013 Using Outlook 3
Semipro50 CATEGORIES Using Outlook 4
B Outlook 2013 categories Using Outlook 1
N Using Categories & Search Folders with multiple accounts Using Outlook 4
D Multiple values for a field (like categories) Outlook VBA and Custom Forms 1

Similar threads

Back
Top