查看文章 |
最近研究VSTO, 找了好多资料, 国内做这方面的太少了. 有一个需求是要修改OutLook中某个界面的UI, 经过与微软全球技术支持中心的讨论, 得出这个是无法实现的, 只能用自定义窗体来代替原有界面. 以下是一个VB代码( OUTLOOK2007 ): Public Class ThisAddIn
Private WithEvents tyINS As Outlook.Inspectors Private WithEvents tyAI As Outlook.AppointmentItem
Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
tyINS = Me.Application.Inspectors
End Sub
Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown
End Sub
Private Sub tyINS_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles tyINS.NewInspector tyAI.S() tyAI = Inspector.CurrentItem If tyAI.MessageClass = "IPM.Appointment" Then Dim f As New TyApptItem() f.Show() Else
End If End Sub
Private Sub tyAI_Open(ByRef Cancel As Boolean) Handles tyAI.Open Cancel = True End Sub
Private Sub tyAI_Send() Handles tyAI. End Class 代码中的窗体是自己随便建的. C# 代码(OUTLOOK2003): public partial class ThisApplication { Outlook.Inspectors tyINS; Outlook.AppointmentItem tyAO;
private void ThisApplication_Startup(object sender, System.EventArgs e) { tyINS = this.Inspectors;
tyINS.NewInspector += new Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(tyINS_NewInspector);
}
void tyINS_NewInspector(Microsoft.Office.Interop.Outlook.Inspector Inspector) { tyAO = (Outlook.AppointmentItem)Inspector.CurrentItem; tyAO.Open += new Microsoft.Office.Interop.Outlook.ItemEvents_10_OpenEventHandler(tyAO_Open); if (tyAO.MessageClass == "IPM.Appointment") { Form1 f = new Form1(); f.Show(); } }
void tyAO_Open(ref bool Cancel) { Cancel = true; tyAO.Open -= new Microsoft.Office.Interop.Outlook.ItemEvents_10_OpenEventHandler(tyAO_Open); }
private void ThisApplication_Shutdown(object sender, System.EventArgs e) { }
#region VSTO generated code
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InternalStartup() { this.Startup += new System.EventHandler(ThisApplication_Startup); this.Shutdown += new System.EventHandler(ThisApplication_Shutdown); }
#endregion }
|