EWS-访问共享日历项目/约会 [英] EWS - Access Shared Calendars Items/Appointments
问题描述
我正在尝试获取共享日历的所有项目(我一直关注 EWS-从Glen Scales访问所有共享日历),但它仅在共享日历( Calendrierspartagés)下列出文件夹(法文),我找不到通用视图是否应该本地化
I'm trying to get all items of a shared calendar (I've followed EWS - Access All Shared Calendars from Glen Scales), but it only lists Folders under "Shared Calendars" ("Calendriers partagés" as it's in French, I can't find if "Common Views" should is localized either, I don't think so).
一个同事创建了一个带有几个约会的日历,与我共享,并给了我最大的测试权限(所有权)。
A coworker created a calendar with a few appointments, shared it with me and gave me maximum permissions (ownership) for testing.
如何访问此共享日历中的项目/约会(在C#/ PowerShell中)?
How do you access the Items/Appointments within this shared calendar (in C#/PowerShell)?
更多信息:
建议使用Folder.Bind,但该调用会产生异常:
More info: It's recommended to use Folder.Bind, but the call generates an exception:
ExchangeService service = new ExchangeService(ExchangeVersion.ExchangeVersion);
service.Credentials = new WebCredentials("login", "****");
service.Url = new Uri("https://.../ews/exchange.asmx");
try {
FolderId cfolderid = new FolderId(WellKnownFolderName.Calendar, "coworker@domain.com");
Folder TargetFolder = Folder.Bind(service, cfolderid);
Console.WriteLine("target folder = " + TargetFolder);
} catch (Exception ex){
Console.WriteLine(ex.ToString());
}
Microsoft.Exchange.WebServices.Data.ServiceResponseException: Le dossier spécifié est introuvable dans la banque d'informations.
à Microsoft.Exchange.WebServices.Data.ServiceResponse.InternalThrowIfNecessary()
à Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
à Microsoft.Exchange.WebServices.Data.ExchangeService.BindToFolder(FolderId folderId, PropertySet propertySet)
à Microsoft.Exchange.WebServices.Data.ExchangeService.BindToFolder[TFolder](FolderId folderId, PropertySet propertySet)
à Microsoft.Exchange.WebServices.Data.Folder.Bind(ExchangeService service, FolderId id)
à ConsoleApplication.Program.Main(String[] args)
附录:我从Glen's co重新开始de,痕迹显示为注释。 WlinkAddressBookEIDA为空。
Addendum: I restarted with Glen's code, traces shown as comments. WlinkAddressBookEIDA is null.
static Dictionary<string, Folder> GetSharedCalendarFoldersA(ExchangeService service, String mbMailboxname)
{
Dictionary<String, Folder> rtList = new System.Collections.Generic.Dictionary<string, Folder>();
FolderId rfRootFolderid = new FolderId(WellKnownFolderName.Root, mbMailboxname);
FolderView fvFolderView = new FolderView(1000);
SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(FolderSchema.DisplayName, "Common Views");
FindFoldersResults ffoldres = service.FindFolders(rfRootFolderid, sfSearchFilter, fvFolderView);
if (ffoldres.Folders.Count == 1)
{
PropertySet psPropset = new PropertySet(BasePropertySet.FirstClassProperties);
ExtendedPropertyDefinition PidTagWlinkAddressBookEID = new ExtendedPropertyDefinition(0x6854, MapiPropertyType.Binary);
ExtendedPropertyDefinition PidTagWlinkFolderType = new ExtendedPropertyDefinition(0x684F, MapiPropertyType.Binary);
ExtendedPropertyDefinition PidTagWlinkGroupName = new ExtendedPropertyDefinition(0x6851, MapiPropertyType.String);
psPropset.Add(PidTagWlinkAddressBookEID);
psPropset.Add(PidTagWlinkFolderType);
ItemView iv = new ItemView(1000);
iv.PropertySet = psPropset;
iv.Traversal = ItemTraversal.Associated;
SearchFilter cntSearch = new SearchFilter.IsEqualTo(PidTagWlinkGroupName, "Calendriers partagés"); // localized
FindItemsResults<Item> fiResults = ffoldres.Folders[0].FindItems(cntSearch, iv);
Console.WriteLine("fiResults TotalCount = " + fiResults.TotalCount) ; // OK -> 1
foreach (Item itItem in fiResults.Items)
{
Console.WriteLine("itItem Subject = " + itItem.Subject); // OK, my coworker shared calendar
Console.WriteLine("itItem Id = " + itItem.Id); // Id but not the one expected!
object WlinkAddressBookEIDA = null;
itItem.TryGetProperty(PidTagWlinkAddressBookEID, out WlinkAddressBookEIDA);
Console.WriteLine("WlinkAddressBookEIDA = " + WlinkAddressBookEIDA + " is null ? " + (WlinkAddressBookEIDA == null)); // KO -> WlinkAddressBookEIDA = is null ? True
try{[...]
推荐答案
我也找不到通用视图是否应该本地化,我也不认为)
I can't find if "Common Views" should is localized either, I don't think so)
不需要,您可以使用EWSEditor浏览Non_IPM子文件夹,该子文件夹会告诉您两种方式
It shouldn't need to be you can use the EWSEditor to browse the Non_IPM Subfolders which will tell you either way
一个同事创建了一个带有几个约会的日历,与我共享了日历,并给了我最大的测试权限(所有权)。
如何访问此共享日历中的项目/约会(在C#/ PowerShell中)?
A coworker created a calendar with a few appointments, shared it with me and gave me maximum permissions (ownership) for testing. How do you access the Items/Appointments within this shared calendar (in C#/PowerShell)?
共享日历的人的电子邮件地址,然后仅对邮箱使用FolderId重载并将其直接绑定,例如
If you know the EmailAddress of the person who has shared their calendar then just use the FolderId overload for Mailbox and bind to it directly eg
FolderId cfolderid = new FolderId(WellKnownFolderName.Calendar, "Mailbox@domain.com");
Folder TargetFolder = Folder.Bind(service, cfolderid);
这篇关于EWS-访问共享日历项目/约会的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!