检查初始发送邀请后已更新的约会项目

问题描述

我有一个与项目发送事件相关的 Outlook 插件。当用户单击发送时,我会得到一个收件人列表并检查外部地址。 我需要能够区分发送原始项目后更新的 Outlook 约会项目。

是否有 DASL 属性、赎回属性或标准约会项目属性来确定这一点?

对于mailitems,我检查ConversationIndex字符串的长度,如果长度是44,我就知道这是一条新消息。如果大于 44,我就知道是回复或转发。

//for example
Outlook.MailItem mailItem = Item as Outlook.MailItem;
string convID = mailItem.ConversationIndex;
if ((convID.Length = 44)) //new messages are always 44 
{ //do something }

我希望对新约会项目进行类似检查,但约会项目的对话指数并未增加

此问题 - link - 类似但不相同,因为在发送项目后 FInvited DASL 属性始终为真。

解决方法

我能够通过订阅 Outlook.InspectorsEvents_NewInspectorEventHandler 事件来检查新的会议/约会项目,并且当该事件被触发时,您可以检查 fInvited DASL 属性。由于此事件在 ItemSend 事件之前触发,因此我始终知道当前项目的 fInvited 值。

这里有一个例子,希望以后能帮助到其他人:

private void ThisAddIn_Startup(object sender,System.EventArgs e)
        {
            olInspectors = this.Application.Inspectors;
            olInspectors.NewInspector += new Outlook.InspectorsEvents_NewInspectorEventHandler(Compose_New_Message_Inspector);

        }

        public bool AppointmentSent { get; set; }
        static void Main(string[] args)
        {

            void Compose_New_Message_Inspector(Microsoft.Office.Interop.Outlook.Inspector Inspector)
            {
                try
                {
                    var Item = Inspector.CurrentItem;
                    if (Item is Outlook.MailItem)
                    {
                       //not concerned with mail items 
                    }
                    else if (Item is Outlook.AppointmentItem)
                    {
                       
                        // added to check if an appontment is new or if it's beeing updated or has alredy been sent
                        // fInvited=false if meeting is newly composed and true if it has already been sent  
                        Outlook.AppointmentItem apptItem = Item as Outlook.AppointmentItem;
                        bool fInvited;
                        try
                        {
                            fInvited = apptItem.PropertyAccessor.
                                GetProperty("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/8229000B");
                            Debug.WriteLine("fInvited =" + fInvited);
                            AppointmentSent = fInvited;
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine(ex);
                        }
                        try
                        {
                            if (apptItem != null)
                            {
                                Marshal.ReleaseComObject(apptItem);
                            }
                        }
                        catch (Exception ex)
                        {
                        }

                    }

                    // To hangle right-click action (Forward Meeting or Foward occurrences) 
                    // fInvited=false if meeting is newly composed and true if it has already been sent  
                    else if (Item is Outlook.MeetingItem)
                    {
                        Outlook.MeetingItem meetingItem = Item as Outlook.MeetingItem;
                        bool fInvited;
                        try
                        {
                            fInvited = meetingItem.PropertyAccessor.
                                GetProperty("http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/8229000B");
                            Debug.WriteLine("fInvited =" + fInvited);
                            AppointmentSent = fInvited;
                        }
                        catch (Exception ex)
                        {
                            Debug.WriteLine(ex);
                        }
                        try
                        {
                            if (meetingItem != null)
                            {
                                Marshal.ReleaseComObject(meetingItem);
                            }
                        }
                        catch (Exception ex)
                        {
                        }

                    }

                    try
                    {
                        if (Item != null)
                        {
                            Marshal.ReleaseComObject(Item);
                        }

                    }
                    catch (Exception ex)
                    {

                    }

                }

                catch (Exception ex)
                {
                    
                }
            }
        }

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...