2

您好 Exchange 开发人员,

我通过 Exchange Web 服务 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-...”)。有人解决这样的问题吗?感谢您的关注。

4

2 回答 2

1

感谢您的回答。

看来我解决了这个问题。看起来“Id”属性(Category 类)的内容应该用大括号括起来。就我而言,我将“Guid”类型用于“Id”属性。序列化程序应用了“ToString”方法,“Id”属性看起来像“e6de9b1b-a81c-46f6-81b3-c23edfab4478”,但有效值为“{e6de9b1b-a81c-46f6-81b3-c23edfab4478}”。所以我将“Id”属性的类型更改为“string”。有效版本如下所示:

var list = MasterCategoryList.Bind(service);

list.Categories.Add(

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

});

请注意。

于 2013-07-03T11:11:00.223 回答
0

如果问题出在 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 ...

于 2013-07-03T09:44:27.620 回答