ÓÐÒ»¸öÐèÇóÊÇÒªÐÞ¸ÄOutLookÖÐij¸ö½çÃæµÄ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
}