2016-12-12 1 views
1

Exchange EWS API를 사용하여 공유 일정 만 검색하는 방법은 무엇입니까?EWS 관리 API를 사용하여 공유 일정에 액세스하는 방법

Exchange EWS API를 사용하여 어떤 캘린더를 공유하는지 어떻게 알 수 있습니까?

+0

먼저 아래 코드를 사용하여 모든 캘린더를 호출합니다. FolderView fvFolderView = 새 FolderView (1000); fvFolderView.Traversal = FolderTraversal.Deep; SearchFilter sfSearchFilter = new SearchFilter.IsEqualTo (FolderSchema.FolderClass, "IPF.Appointment"); FindFoldersResults ffoldres = service.FindFolders (새 FolderId (WellKnownFolderName.Root, "이메일 @ 주소"), sfSearchFilter, fvFolderView); 이제 3 개의 캘린더가 생기고 하나의 공유 캘린더가 포함됩니다. 공유 캘린더를 찾아야합니다. –

답변

2

FolderId에 액세스하려는 캘린더 만 지정할 수 있습니다.

FolderId folderIdFromCalendar = new FolderId(WellKnownFolderName.Calendar, "[email protected]"); 

그런 다음, 원하는 일정 항목을 검색하는 folderIdFromCalendar을 사용할 수 있습니다 예 :

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

프로그램이 사서함이있는 사용자의 컨텍스트에서 실행되어야 함을 기억 와 공유 된.

업데이트 :

FolderId을 알고 일 경우 현재 사용자가이 코드를 수행하여이 달력에 액세스 할 수있는 경우에, 당신은 단지, 확인할 수 있습니다 위와

을, 당신이를 초기화해야합니다 FolderId :

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."); 
    } 
: 그 후

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

는 다음 코드를 시도

또 다른 업데이트 :

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, "[email protected]"); 
    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]는"이 프로그램에 어떤 영향을 미치는지, 이해가 안 :하지만 솔직히, 나는 다음과 같은 코드에서 벌어지고있는 모든 것을 이해하지 못하는 구문에는 문자열이 필요합니다.

+0

나는 예를 들어 het와 같은 사용자 이메일 아이디를 모른다. "[email protected]"이메일 아이디를 모른다. 나는 C#에서 일하고 있으며 내 계정에서 공유 캘린더를 알고있다. –

+0

EWS에 어떤 종류의 정보를주고, 어디에서 항목을 가져올 수 있는지에 대해서는 거의 불가능합니다. – NotTelling

+0

당신에 따르면 우리 계정에서 공유 캘린더를 찾을 방법이 없습니까? –

관련 문제