百度首页 | 百度空间
 
查看文章
 
VS 2008 VSTO 开发: 替换OutLook中已有功能
2008-01-10 11:06

最近研究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

    }


类别:.net 技术 | 添加到搜藏 | 浏览() | 评论 (0)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码:
 

     

©2008 Baidu