gpt4 book ai didi

exchangewebservices - 如何使用 EWS 托管 API 访问共享日历

转载 作者:行者123 更新时间:2023-12-02 04:02:51 25 4
gpt4 key购买 nike

如何使用 Exchange EWS API 仅检索共享日历。

我如何知道使用 Exchange EWS API 共享哪个日历。

最佳答案

您只需在 FolderId 中指定要访问的日历即可。

FolderId folderIdFromCalendar = new FolderId(WellKnownFolderName.Calendar, "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="05766d647760614c6b676a7d45607d64687569602b666a68" rel="noreferrer noopener nofollow">[email protected]</a>");

然后,您可以使用 folderIdFromCalendar 检索您想要的日历项目,例如:

FindItemsResults<Item> appointments = ExchangeServive.FindItems(folderIdFromCalendar, ItemView);

请记住,程序必须在共享邮箱的用户上下文中运行。

更新:

如果您碰巧知道 FolderId,则只需执行以下代码即可检查当前用户是否有权访问此日历:

如上所述,您需要初始化一个FolderId:

FolderId folderIdFromCalendar = new FolderId("AQMkADAwATM3ZmYAZS1kNjE0LWU1ZmQtMDACLTAwCgAuAAADJRMtiupYBUGD‌​cKdcqUrr3AEA1/sqwbrw‌​UEeFM0Mc+UBFoQAAABzk‌​m1sAAAA=");

之后,尝试以下代码:

if (folderIdFromCalendar != null)
{
try
{
ItemView cView = new ItemView(1000);
FindItemsResults<Item> appointments = service.FindItems(folderIdFromCalendar, cView);
int count = appointments.TotalCount; //just an example of some random action on the folder calendar
}
catch (ServiceResponseException ex)
{
Console.WriteLine("The specified calendar was not shared with you. \n" + ex);
}
}
else
{
Console.WriteLine("The specified calendar ID could not be linked to a calendar folder.");
}

另一个更新:

if (folderIdFromCalendar != null)
{
if (folderIdFromCalendar.Mailbox.ToString().ToLower() == "your-Mailadress".ToLower())
{
Console.WriteLine("The folder you specified is your own");
}
else
{
try
{
ItemView cView = new ItemView(1000);
FindItemsResults<Item> appointments = service.FindItems(folderIdFromCalendar, cView);
int count = appointments.TotalCount; //just an example of some random action on the folder calendar
Console.WriteLine("You have been given access to this mailbox. Its owner is: " + folderIdFromCalendar.Mailbox.ToString()); //if you need to know, whos mailbox you are accessing right now
}
catch (ServiceResponseException ex)
{
Console.WriteLine("The specified calendar was not shared with you. \n" + ex);
}
}
}
else
{
Console.WriteLine("The specified calendar ID could not be linked to a calendar folder.");
}

最后更新:

我现在已经用谷歌搜索了很多,找到了一些对我有用的东西。但说实话,我并不理解以下代码中发生的一切:

FolderId folderIdFromCalendar = new FolderId("AQMkADAwATM3ZmYAZS1kNjE0LWU1ZmQtMDACLTAwCgAuAAADJRMtiupYBUGD‌​cKdcqUrr3AEA1/sqwbrw‌​UEeFM0Mc+UBFoQAAABzk‌​m1sAAAA=");
Folder folderFromCalendar = Folder.Bind(service, folderIdFromCalendar);

AlternateId aiAlternateid = new AlternateId(IdFormat.EwsId, folderFromCalendar.Id.UniqueId, "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="92e0f3fcf6fdffd2fff3fbfef3f6e0f7e1e1bcf1fdff" rel="noreferrer noopener nofollow">[email protected]</a>");
AlternateIdBase aiResponse = service.ConvertId(aiAlternateid, IdFormat.EwsId);

var mailbox = ((AlternateId)aiResponse).Mailbox;

if (folderFromCalendar != null)
{
if (mailbox.ToString().ToLower() == "your-Mailadress".ToLower())
{
Console.WriteLine("The folder you specified is your own");
}
else
{
try
{
ItemView cView = new ItemView(1000);
FindItemsResults<Item> appointments = service.FindItems(folderIdFromCalendar, cView);
int count = appointments.TotalCount; //just an example of some random action on the folder calendar
Console.WriteLine("You have been given access to this mailbox. Its owner is: " + mailbox.ToString());
}
catch (ServiceResponseException ex)
{
Console.WriteLine("The specified calendar was not shared with you. \n" + ex);
}
}
}
else
{
Console.WriteLine("The specified calendar ID could not be linked to a calendar folder.");
}

我不明白字符串“[email protected]”如何影响该程序中的任何内容,但语法需要一个字符串。

关于exchangewebservices - 如何使用 EWS 托管 API 访问共享日历,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41095971/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com