MS Outlook 2013删除通过Exchange Web Services API添加到主分类列表中的自定义类别

本文关键字:列表 分类 自定义 添加 API 删除 2013 Outlook Services Web Exchange | 更新日期: 2023-09-27 18:20:50

你好,交易所开发人员,

我通过Exchange Web Services API成功地将多个自定义类别添加到MasterCategoryList中。我用了一个样本:

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

});

但过了一段时间,我注意到由于某种原因,我的自定义类别从MasterCategoryList中消失了。尽管我将"Guid.NewGuid()"分配给了"Id"属性,但经过一段时间后MS Exchange将其无效("0000-0000-…"),我还是发现了这一点。有人能解决这样的问题吗?感谢您的关注。

MS Outlook 2013删除通过Exchange Web Services API添加到主分类列表中的自定义类别

感谢您的回答。

看来我解决了这个问题。似乎"Id"属性(Category类)的内容应该用花括号括起来。在我的案例中,我使用"Guid"类型作为"Id"属性。序列化程序应用了"ToString"方法,"Id"属性看起来像"e6de9b1b-a81c-46f6-81b3-c23edfab4478",但有效值是"{e6de9 b1b-a81 c-46f6-81b3-c23 edfab4478}"。所以我把"Id"属性的类型改为"string"。有效版本看起来像:

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

请注意。

如果问题出现在Outlook中,而不是Exchange中,也许您可以尝试以下方法:

检索主类别列表的SOAP调用:

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

响应:

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

该XMLData是Base64编码的,如果解码为:

<?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>

也许你可以用它做点什么,使用SetUserConfiguration。。。