2013-03-21 26 views
0

我正在使用C#爲Outlook創建外接程序,我希望能夠檢查日曆(我的和其他人)的可用性。我嘗試使用GetSharedDefaultFolder(),但它只與那些明確授予我許可的人合作,即使我公司的所有日曆都可以被其他人查看(我們可以看到約會的主題和時間)。無論如何,我可以得到這些信息嗎?謝謝。C#Outlook附加組件:檢查日曆可用性

編輯:我想強調的是,我的問題是與GetSharedDefaultFolder(),而不是GetDefaultFolder()日曆可用性,而不是(即觀看別人的同時,我只需要能夠檢查他人的日曆。)充分利用日曆。

回答

1

不要直接訪問該文件夾 - 使用Recipient.FreeBusy或AddressEntry.GetFreeBusy

+0

感謝德米特里,這有助於。 – Rafid 2013-03-21 16:02:47

1

嘗試這個>>

public void GetAllCalendarItems() 
     { 
      Microsoft.Office.Interop.Outlook.Application oApp = null; 
      Microsoft.Office.Interop.Outlook.NameSpace mapiNamespace = null; 
      Microsoft.Office.Interop.Outlook.MAPIFolder CalendarFolder = null; 
      Microsoft.Office.Interop.Outlook.Items outlookCalendarItems = null; 

      oApp = new Microsoft.Office.Interop.Outlook.Application(); 
      mapiNamespace = oApp.GetNamespace("MAPI"); ; 
      CalendarFolder = mapiNamespace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderCalendar);   outlookCalendarItems = CalendarFolder.Items; 
      outlookCalendarItems.IncludeRecurrences = true; 

      foreach (Microsoft.Office.Interop.Outlook.AppointmentItem item in outlookCalendarItems) 
      { 
       if (item.IsRecurring) 
       { 
        Microsoft.Office.Interop.Outlook.RecurrencePattern rp = item.GetRecurrencePattern(); 
        DateTime first = new DateTime(2008, 8, 31, item.Start.Hour, item.Start.Minute, 0); 
        DateTime last = new DateTime(2008, 10, 1); 
        Microsoft.Office.Interop.Outlook.AppointmentItem recur = null; 



        for (DateTime cur = first; cur <= last; cur = cur.AddDays(1)) 
        { 
         try 
         { 
          recur = rp.GetOccurrence(cur); 
          MessageBox.Show(recur.Subject + " -> " + cur.ToLongDateString()); 
         } 
         catch 
         { } 
        } 
       } 
       else 
       { 
        MessageBox.Show(item.Subject + " -> " + item.Start.ToLongDateString()); 
       } 
      } 

     } 

似乎與此類似問題>

http://www.add-in-express.com/forum/read.php?FID=5&TID=8953

那麼請點擊此鏈接上的討論。這可能對你有所幫助。

+0

謝謝。這可以用來查看我的日曆,但其他人呢?!正如我上面提到的,問題發生在GetSharedDefaultFolder()而不是GetDefaultFolder()。 – Rafid 2013-03-21 11:17:40

+0

通過我的回答鏈接 – 2013-03-21 11:24:14