【问题标题】:Multiple calender in exchange web service交换网络服务中的多个日历
【发布时间】:2014-06-10 13:55:40
【问题描述】:

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

比如我有三个压光机,一个是主压光机

  1. 日历(颜色代码:默认)

  2. 约根(颜色代码:粉红色)

  3. Soren(颜色代码:黄色)

我可以使用以下代码检索主“Calnder”的所有值

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++;

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

【问题讨论】:

  • 这些日历是委托给您的,还是您拥有?
  • 其中一些在我的日历文件夹中并且我拥有它们,一些日历是共享的,需要同时获取拥有和共享的日历

标签: c# asp.net exchangewebservices


【解决方案1】:

要获取位于您自己邮箱中的所有日历文件夹(不包括您的个人存档中的那些),您可以使用深度遍历执行 FindFolders 并过滤文件夹类为 IPF.Appointment 的文件夹比如像

            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 Calendars

干杯 格伦

【讨论】:

    猜你喜欢
    • 2011-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多