MS Outlook 2013 deletes custom categories added into MasterCategoryList via Exchange Web Services API

StackOverflow https://stackoverflow.com/questions/17421559

Pergunta

Hello Exchange developers,

I successfully added several custom categories into MasterCategoryList via Exchange Web Services API. I used a sample:

var list = MasterCategoryList.Bind(service);
list.Categories.Add(
   new Category {
            Name = "Vacation",
            Color = CategoryColor.DarkMaroon,
            KeyboardShortcut = CategoryKeyboardShortcut.CtrlF10,
            Id = Guid.NewGuid()

});

But after some time I noticed my custom categories went away from MasterCategoryList for some reason. I found out despite I assigned "Guid.NewGuid()" to the "Id" property after some time MS Exchange nullify it ("0000-0000-..."). Does anybody solve such a problem? Thanks for your attention.

Foi útil?

Solução

Thanks for your answer.

It seems I resolved this problem. It appeared contents of the "Id" property (Category class) should be wrapped inside curly brackets. In my case I used "Guid" type for "Id" property. Serializer applied "ToString" method and "Id" property looked like "e6de9b1b-a81c-46f6-81b3-c23edfab4478" but valid value is "{e6de9b1b-a81c-46f6-81b3-c23edfab4478}". So I changed type of "Id" property to "string". And valid version looks like:

var list = MasterCategoryList.Bind(service);

list.Categories.Add(

new Category {
        Name = "Vacation",
        Color = CategoryColor.DarkMaroon,
        KeyboardShortcut = CategoryKeyboardShortcut.CtrlF10,
        Id = "{" + Guid.NewGuid() + "}";

});

Please be aware.

Outras dicas

If the issue is in Outlook, not Exchange, maybe you can try something along these lines:

SOAP call to retrieve Master Category List:

<soap:Envelope xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages"
               xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types"
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <typ:RequestServerVersion Version="Exchange2010" />
  </soap:Header>
  <soap:Body>
    <mes:GetUserConfiguration>
      <mes:UserConfigurationName Name="CategoryList">
        <typ:DistinguishedFolderId Id="calendar"/>
      </mes:UserConfigurationName>
      <mes:UserConfigurationProperties>All</mes:UserConfigurationProperties>
    </mes:GetUserConfiguration>
  </soap:Body>
</soap:Envelope>

response:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Header>
      <h:ServerVersionInfo MajorVersion="14" MinorVersion="0" MajorBuildNumber="722" MinorBuildNumber="0" Version="Exchange2010" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
   </s:Header>
   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <m:GetUserConfigurationResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
         <m:ResponseMessages>
            <m:GetUserConfigurationResponseMessage ResponseClass="Success">
               <m:ResponseCode>NoError</m:ResponseCode>
               <m:UserConfiguration>
                  <t:UserConfigurationName Name="CategoryList">
                     <typ:DistinguishedFolderId Id="calendar" xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types"/>
                  </t:UserConfigurationName>
                  <t:ItemId Id="AAMkADky[snip]1VAZmIKAAAKfSM9AAA=" ChangeKey="CQAAAB[snip]AIlsUeV"/>
                  <t:XmlData>PD94bWw[snip]cmllcz4NCg==</t:XmlData>
               </m:UserConfiguration>
            </m:GetUserConfigurationResponseMessage>
         </m:ResponseMessages>
      </m:GetUserConfigurationResponse>
   </s:Body>
</s:Envelope>

That XMLData is Base64 encoded, if you decode it is:

<?xml version="1.0"?>
<categories default="Red Category" lastSavedSession="2" lastSavedTime="2013-04-17T09:10:12.786" xmlns="CategoryList.xsd">
    <category name="Red Category" color="0" keyboardShortcut="0" usageCount="2" lastTimeUsedNotes="1601-01-01T00:00:00.000" lastTimeUsedJournal="1601-01-01T00:00:00.000" lastTimeUsedContacts="1601-01-01T00:00:00.000" lastTimeUsedTasks="1601-01-01T00:00:00.000" lastTimeUsedCalendar="1601-01-01T00:00:00.000" lastTimeUsedMail="1601-01-01T00:00:00.000" lastTimeUsed="2010-09-29T10:08:46.487" lastSessionUsed="0" guid="{61C23D24-ED86-47EC-8565-433E3A6B21B7}" renameOnFirstUse="1"/>
    <category name="Blue Category" color="7" keyboardShortcut="0" usageCount="6" lastTimeUsedNotes="1601-01-01T00:00:00.000" lastTimeUsedJournal="1601-01-01T00:00:00.000" lastTimeUsedContacts="1601-01-01T00:00:00.000" lastTimeUsedTasks="1601-01-01T00:00:00.000" lastTimeUsedCalendar="2013-04-17T09:10:04.043" lastTimeUsedMail="1601-01-01T00:00:00.000" lastTimeUsed="2013-04-17T09:10:04.043" lastSessionUsed="2" guid="{E19DD512-BFF1-46D8-A858-54CC114872AD}"/>
    <category name="Purple Category" color="8" keyboardShortcut="0" usageCount="2" lastTimeUsedNotes="1601-01-01T00:00:00.000" lastTimeUsedJournal="1601-01-01T00:00:00.000" lastTimeUsedContacts="1601-01-01T00:00:00.000" lastTimeUsedTasks="1601-01-01T00:00:00.000" lastTimeUsedCalendar="1601-01-01T00:00:00.000" lastTimeUsedMail="1601-01-01T00:00:00.000" lastTimeUsed="2010-09-29T10:08:46.487" lastSessionUsed="0" guid="{FD3AFB30-285E-4BF2-885E-F9FDFE00002E}" renameOnFirstUse="1"/>
    <category name="Green Category" color="4" keyboardShortcut="0" usageCount="6" lastTimeUsedNotes="1601-01-01T00:00:00.000" lastTimeUsedJournal="1601-01-01T00:00:00.000" lastTimeUsedContacts="1601-01-01T00:00:00.000" lastTimeUsedTasks="1601-01-01T00:00:00.000" lastTimeUsedCalendar="2013-04-17T09:10:12.782" lastTimeUsedMail="1601-01-01T00:00:00.000" lastTimeUsed="2013-04-17T09:10:12.782" lastSessionUsed="2" guid="{C3DC51D0-1CC4-42CF-9FA9-75146905771F}"/>
    <category name="Orange Category" color="1" keyboardShortcut="0" usageCount="2" lastTimeUsedNotes="1601-01-01T00:00:00.000" lastTimeUsedJournal="1601-01-01T00:00:00.000" lastTimeUsedContacts="1601-01-01T00:00:00.000" lastTimeUsedTasks="1601-01-01T00:00:00.000" lastTimeUsedCalendar="1601-01-01T00:00:00.000" lastTimeUsedMail="1601-01-01T00:00:00.000" lastTimeUsed="2010-09-29T10:08:46.487" lastSessionUsed="0" guid="{10C78B6F-5828-4B3C-AF0C-138AAAC52DAE}" renameOnFirstUse="1"/>
    <category name="Yellow Category" color="3" keyboardShortcut="0" usageCount="2" lastTimeUsedNotes="1601-01-01T00:00:00.000" lastTimeUsedJournal="1601-01-01T00:00:00.000" lastTimeUsedContacts="1601-01-01T00:00:00.000" lastTimeUsedTasks="1601-01-01T00:00:00.000" lastTimeUsedCalendar="1601-01-01T00:00:00.000" lastTimeUsedMail="1601-01-01T00:00:00.000" lastTimeUsed="2010-09-29T10:08:46.487" lastSessionUsed="0" guid="{37CC21D3-B6A9-4DAE-A1FB-422249B9FBB0}" renameOnFirstUse="1"/>
    <category name="TimeTell" color="7" keyboardShortcut="0" usageCount="7" lastTimeUsedNotes="1601-01-01T00:00:00.000" lastTimeUsedJournal="1601-01-01T00:00:00.000" lastTimeUsedContacts="1601-01-01T00:00:00.000" lastTimeUsedTasks="1601-01-01T00:00:00.000" lastTimeUsedCalendar="2013-04-17T09:09:59.980" lastTimeUsedMail="1601-01-01T00:00:00.000" lastTimeUsed="2013-04-17T09:09:59.980" lastSessionUsed="2" guid="{3348E50B-1763-42FB-A9E9-25B74038B9AA}"/>
</categories>

Maybe you can do something with this, use SetUserConfiguration...

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top