2017-04-25 9 views
1

私は、Exchangeからのミーティングにアクセスするアプリケーションを構築しています。私はEWSのドキュメントでMicrosoftが提供するコードを使用しています。問題は特定のカレンダーにアクセスする必要があることです。さあ、私はデフォルトのものから2カレンダーを作成します。このコードを使用して会議にアクセスすると、既定の予定表からのみ会議が行われます。特定のカレンダーから会議にアクセスしたいこれどうやってするの?特定のカレンダーのAcess会議EWS(C#)

ありがとうございました。

// Initialize values for the start and end times, and the number of appointments to retrieve. 
 
      DateTime startDate = DateTime.Now; 
 
      DateTime endDate = startDate.AddDays(30); 
 
      const int NUM_APPTS = 5; 
 

 
      // Initialize the calendar folder object with only the folder ID. 
 
      CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet()); 
 

 
      // Set the start and end time and number of appointments to retrieve. 
 
      CalendarView cView = new CalendarView(startDate, endDate, NUM_APPTS); 
 

 
      // Limit the properties returned to the appointment's subject, start time, and end time. 
 
      cView.PropertySet = new PropertySet(AppointmentSchema.Subject, AppointmentSchema.Start, AppointmentSchema.End); 
 

 
      // Retrieve a collection of appointments by using the calendar view. 
 
      FindItemsResults<Appointment> appointments = calendar.FindAppointments(cView); 
 

 
      Console.WriteLine("\nThe first " + NUM_APPTS + " appointments on your calendar from " + startDate.Date.ToShortDateString() + 
 
           " to " + endDate.Date.ToShortDateString() + " are: \n"); 
 
      
 
      foreach (Appointment a in appointments) 
 
      { 
 
       Console.Write("Subject: " + a.Subject.ToString() + " "); 
 
       Console.Write("Start: " + a.Start.ToString() + " "); 
 
       Console.Write("End: " + a.End.ToString()); 
 
       Console.WriteLine(); 
 
      }

答えて

0

私はあなたの問題はあなたがWellKnownFolderName.Calendarを使用していることだと思う:

CalendarFolder calendar = CalendarFolder.Bind(service, WellKnownFolderName.Calendar, new PropertySet()); 

をする代わりに、あなたが作成したカレンダーのフォルダIDを使用する必要があります。あなたは(答えで見つかった:https://stackoverflow.com/a/24133821/1037864)このようなコードを使用することができますフォルダ(カレンダー)のIDを取得するには

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.Id.ToString() + " " + fld.DisplayName); 
     } 
    } 

fld.Idから値を取り、WellKnownFolderName.Calendarの代わりに使用します。

(私はこれを試してみるために今すぐExchangeサーバを利用できませんが、私はあなたがアイデアを得て、私のコードが正しいことを願っています)