本文主要是介绍Outlook打开工享Calendar,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
其实……通过Outlook的Application我们是不能直接访问人家的Calendar的。所以我们要绕个圈子去访问它。
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 Ribbon1_Load(object sender, RibbonUIEventArgs e){}private void button1_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();}}}}}}}}
}
如果你没有访问权限,这个代码会出错。
相关资源:http://download.csdn.net/detail/tx_officedev/3962208
这篇关于Outlook打开工享Calendar的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!