exchange web服务中的多个日历

本文关键字:日历 web 服务 exchange | 更新日期: 2023-09-27 18:07:36

我的邮箱里有多个日历。我只能使用ews api 2.0检索一个日历,它是主日历文件夹。现在我想要完整的日历、约会和会议列表。

例如,我有三个日历,其中一个是主日历

  1. 日历(区分颜色:默认)

  2. Jorgen(区分颜色:粉红色)

  3. 索伦(区分颜色:黄色)

我可以检索主"日历"的所有值,使用下面的代码

Folder inbox = Folder.Bind(service, WellKnownFolderName.Calendar);
view.PropertySet = new PropertySet(BasePropertySet.IdOnly);
// This results in a FindItem call to EWS.
FindItemsResults<Item> results = inbox.FindItems(view);
i = 1;
m = results.TotalCount;
if (results.Count() > 0)
{
    foreach (var item in results)
    {
        PropertySet props = new PropertySet(AppointmentSchema.MimeContent, 
            AppointmentSchema.ParentFolderId, AppointmentSchema.Id, 
            AppointmentSchema.Categories, AppointmentSchema.Location);
        // This results in a GetItem call to EWS.
        var email = Appointment.Bind(service, item.Id, props);

        string iCalFileName = @"C:'export'appointment" +i ".ics";

        // Save as .eml.
        using (FileStream fs = new FileStream(iCalFileName, FileMode.Create, FileAccess.Write))
        {
            fs.Write(email.MimeContent.Content, 0, email.MimeContent.Content.Length);
        }
        i++;

现在我想获得所有剩余的日历时间表,我无法获得它。

exchange web服务中的多个日历

要获取位于您自己的邮箱中的所有日历文件夹(如果您有个人存档,则不包括这些文件夹),您可以对具有IPF文件夹类的文件夹执行带有深度遍历的FindFolders和过滤器。约会,例如

            ExtendedPropertyDefinition PR_Folder_Path = new ExtendedPropertyDefinition(26293, MapiPropertyType.String);
        PropertySet psPropSet = new PropertySet(BasePropertySet.FirstClassProperties);
        psPropSet.Add(PR_Folder_Path);
        FolderId rfRootFolderid = new FolderId(WellKnownFolderName.Root, mbMailboxname);
        FolderView fvFolderView = new FolderView(1000);
        fvFolderView.Traversal = FolderTraversal.Deep;
        fvFolderView.PropertySet = psPropSet;
        SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo(FolderSchema.FolderClass, "IPF.Appointment");
        FindFoldersResults ffoldres = service.FindFolders(rfRootFolderid, sfSearchFilter, fvFolderView);
        if (ffoldres.Folders.Count > 0) {
            foreach (Folder fld in ffoldres.Folders) {
                Console.WriteLine(fld.DisplayName);
            }
        }

对于共享日历,你需要使用EWS - Access All Shared calendar

干杯格伦