C# MS Outlook 2013通过Exchange Web服务API删除添加到MasterCategoryList中的自定义类别
您好,Exchange开发者 我通过Exchange Web服务API成功地将几个自定义类别添加到MasterCategoryList。我使用了一个样本: }))C# MS Outlook 2013通过Exchange Web服务API删除添加到MasterCategoryList中的自定义类别,c#,exchangewebservices,ews-managed-api,C#,Exchangewebservices,Ews Managed Api,您好,Exchange开发者 我通过Exchange Web服务API成功地将几个自定义类别添加到MasterCategoryList。我使用了一个样本: })) 但过了一段时间,我注意到由于某种原因,我的自定义类别从MasterCategoryList中消失了。尽管我在一段时间后将“Guid.NewGuid()”分配给了“Id”属性,但我还是发现了这一点,MS Exchange使其无效(“0000-0000-…”)。有人能解决这样的问题吗?感谢您的关注。如果问题出现在Outlook中,而不是E
但过了一段时间,我注意到由于某种原因,我的自定义类别从MasterCategoryList中消失了。尽管我在一段时间后将“Guid.NewGuid()”分配给了“Id”属性,但我还是发现了这一点,MS Exchange使其无效(“0000-0000-…”)。有人能解决这样的问题吗?感谢您的关注。如果问题出现在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>
无误
PD94bWw[snip]cmllcz4NCg==
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做些什么…谢谢您的回答 看来我解决了这个问题。似乎“Id”属性(Category类)的内容应该用花括号括起来。在我的例子中,我使用“Id”属性的“Guid”类型。序列化程序应用了“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() + "}";
});
请注意。您的意思是您的自定义类别会从主列表或个人约会中消失(请编辑问题)?我不知道EWS API的具体情况,我使用原始SOAP调用,但在那里我必须一次替换所有约会类别。所以,要添加一个,检索全部,将一个添加到我的内存列表中,然后将它们全部写回约会。你好,Jan。据我所知,MS Outlook 2013存在问题。我做了以下操作:你好,简。据我所知,MS Outlook 2013存在问题。我通过EWS API将自定义类别插入MasterCategoryList。例如,通过MS Outlook 2013桌面客户端添加新类别。之后,我通过EWS检索MasterCategoryList。类别的所有ID变为“00000000-0000-0000-0000-000000000000”。一段时间后,Exchange将删除除一个之外的所有自定义类别。我想是因为重复的ID。你能告诉我更多关于SOAP呼叫的情况吗?
var list = MasterCategoryList.Bind(service);
list.Categories.Add(
new Category {
Name = "Vacation",
Color = CategoryColor.DarkMaroon,
KeyboardShortcut = CategoryKeyboardShortcut.CtrlF10,
Id = "{" + Guid.NewGuid() + "}";
});