A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook - Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Categories Not Saved



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 22nd 09, 07:24 PM posted to microsoft.public.outlook.program_forms
spottedmahn
external usenet poster
 
Posts: 16
Default Categories Not Saved

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.
  #2  
Old June 23rd 09, 02:41 PM posted to microsoft.public.outlook.program_forms
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Categories Not Saved

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

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"spottedmahn" wrote in message
...
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.


  #3  
Old June 23rd 09, 07:07 PM posted to microsoft.public.outlook.program_forms
spottedmahn
external usenet poster
 
Posts: 16
Default Categories Not Saved

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.olCategoryShortcutKe yNone;

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

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

string CatSifMembersName = "SIF - Members";
Outlook.OlCategoryColor CatSifMemberColor =
Outlook.OlCategoryColor.olCategoryColorRed;
Outlook.OlCategoryShortcutKey CatSifMemberKey =
Outlook.OlCategoryShortcutKey.olCategoryShortcutKe yCtrlF2;

string CatSifVendorsName = "SIF - Vendor";
Outlook.OlCategoryColor CatSifVendorsColor =
Outlook.OlCategoryColor.olCategoryColorOrange;
Outlook.OlCategoryShortcutKey CatSifVendorsKey =
Outlook.OlCategoryShortcutKey.olCategoryShortcutKe yNone;

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

string CatTechDevName = "Tech - Dev";
Outlook.OlCategoryColor CatTechDevColor =
Outlook.OlCategoryColor.olCategoryColorGreen;
Outlook.OlCategoryShortcutKey CatTechDevKey =
Outlook.OlCategoryShortcutKey.olCategoryShortcutKe yNone;

string CatTechSuportName = "Tech - Support";
Outlook.OlCategoryColor CatTechSupportColor =
Outlook.OlCategoryColor.olCategoryColorYellow;
Outlook.OlCategoryShortcutKey CatTechSupportKey =
Outlook.OlCategoryShortcutKey.olCategoryShortcutKe yNone;

public ListOutlookCategory SifCategories
{
get
{
ListOutlookCategory Results = new ListOutlookCategory();

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 IEnumerableOutlook.Category CategoriesList
{
get
{
Outlook.Categories Cats = this.olNS.Categories;

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

//}

IEnumerableOutlook.Category Results =
Cats.CastOutlook.Category();

//ListOutlook.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; }
}
}

"Ken Slovak - [MVP - Outlook]" wrote:

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

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"spottedmahn" wrote in message
...
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.



  #4  
Old June 23rd 09, 07:18 PM posted to microsoft.public.outlook.program_forms
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Categories Not Saved

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.


--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"spottedmahn" wrote in message
news
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.olCategoryShortcutKe yNone;

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

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

string CatSifMembersName = "SIF - Members";
Outlook.OlCategoryColor CatSifMemberColor =
Outlook.OlCategoryColor.olCategoryColorRed;
Outlook.OlCategoryShortcutKey CatSifMemberKey =
Outlook.OlCategoryShortcutKey.olCategoryShortcutKe yCtrlF2;

string CatSifVendorsName = "SIF - Vendor";
Outlook.OlCategoryColor CatSifVendorsColor =
Outlook.OlCategoryColor.olCategoryColorOrange;
Outlook.OlCategoryShortcutKey CatSifVendorsKey =
Outlook.OlCategoryShortcutKey.olCategoryShortcutKe yNone;

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

string CatTechDevName = "Tech - Dev";
Outlook.OlCategoryColor CatTechDevColor =
Outlook.OlCategoryColor.olCategoryColorGreen;
Outlook.OlCategoryShortcutKey CatTechDevKey =
Outlook.OlCategoryShortcutKey.olCategoryShortcutKe yNone;

string CatTechSuportName = "Tech - Support";
Outlook.OlCategoryColor CatTechSupportColor =
Outlook.OlCategoryColor.olCategoryColorYellow;
Outlook.OlCategoryShortcutKey CatTechSupportKey =
Outlook.OlCategoryShortcutKey.olCategoryShortcutKe yNone;

public ListOutlookCategory SifCategories
{
get
{
ListOutlookCategory Results = new
ListOutlookCategory();

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 IEnumerableOutlook.Category CategoriesList
{
get
{
Outlook.Categories Cats = this.olNS.Categories;

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

//}

IEnumerableOutlook.Category Results =
Cats.CastOutlook.Category();

//ListOutlook.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; }
}
}


  #5  
Old June 24th 09, 07:15 PM posted to microsoft.public.outlook.program_forms
spottedmahn
external usenet poster
 
Posts: 16
Default Categories Not Saved

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/b...016B!407.entry


"Ken Slovak - [MVP - Outlook]" 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.


  #6  
Old June 25th 09, 03:52 PM posted to microsoft.public.outlook.program_forms
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Categories Not Saved

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

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"spottedmahn" wrote in message
...
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/b...016B!407.entry


  #7  
Old June 27th 09, 09:07 AM posted to microsoft.public.outlook.program_forms
Michael Bauer [MVP - Outlook]
external usenet poster
 
Posts: 1,885
Default Categories Not Saved



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 - MVP Outlook

: Outlook Categories? Category Manager Is Your Tool
: VBOffice Reporter for Data Analysis & Reporting
: http://www.vboffice.net/product.html?pub=6&lang=en


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/b...016B!407.entry


"Ken Slovak - [MVP - Outlook]" 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.

  #8  
Old June 29th 09, 03:11 PM posted to microsoft.public.outlook.program_forms
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Categories Not Saved

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.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"spottedmahn" wrote in message
...
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/b...016B!407.entry


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Programming custom Categories into Master Categories List John E. Outlook - Using Forms 3 March 30th 09 12:06 PM
Public folder calender categories vs user calander categories Help me Outlook - Calandaring 5 November 2nd 07 08:44 AM
Categories not saved for sent/replied/forwarded messages (O2K7) Lillo Ramos, Alex Outlook - General Queries 3 June 29th 07 09:53 AM
Outlook 2007 Categories are a combo of Categories & Labels in 2003 Scott Sherman Outlook - Calandaring 0 February 13th 07 05:23 AM
Tasks categories. Unable to modify another user's categories. Tommy Outlook - Installation 0 August 9th 06 05:43 PM


All times are GMT +1. The time now is 02:12 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.