Actually ...... Through the Application of Outlook, we cannot directly access others' Calendar. So we need to access it in a circle.
[Csharp]
Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
Using Microsoft. Office. Tools. Ribbon;
Using Outlook = Microsoft. Office. Interop. Outlook;
Using System. Windows. Forms;
Namespace OutlookAddIn26
{
Public partial class Ribbon1
{
Private void ribbonupload load (object sender, RibbonUIEventArgs e)
{
}
Private void button#click (object sender, RibbonControlEventArgs e)
{
Outlook. Application objApplication = Globals. ThisAddIn. Application;
Outlook. Explorer objExplorer = objApplication. ActiveExplorer ();
Outlook. NavigationPane objNavigationPane = objExplorer. NavigationPane;
If (objNavigationPane. CurrentModule. NavigationModuleType = Outlook. OlNavigationModuleType. olModuleCalendar)
{
Outlook. CalendarModule objCalendarModule = objNavigationPane. Modules. GetNavigationModule (Outlook. OlNavigationModuleType. olModuleCalendar) as Outlook. CalendarModule;
Foreach (Outlook. NavigationGroup objNavigationGroup in objCalendarModule. NavigationGroups)
{
Foreach (Outlook. NavigationFolder objNavigationFolder in objNavigationGroup. NavigationFolders)
{
If (objNavigationFolder. DisplayName. IndexOf ("Bruce Song")> = 0)
{
Outlook. MAPIFolder objTargetCalendar = objNavigationFolder. Folder;
Foreach (Outlook. AppointmentItem objAppointimetItem in objTargetCalendar. Items)
{
If (objAppointimetItem. BusyStatus = Outlook. OlBusyStatus. olFree)
{
ObjAppointimetItem. Display ();
}
}
}
}
}
}
}
}
}
If you do not have the access permission, the Code www.2cto.com will fail.
From TX_OfficeDev's column