我已经写了这个小MS Outlook 2003的VSTO外接使用C#和Visual Studio 2008。它的目的是检查每个邮件项目发送的字在体内“附加”,如果找到,则核对数量的附件。如果这个数字是零,然后询问用户是否他们真的是要发送的消息。它应该像Gmail实验室功能,做同样的事的工作。

奇怪的是,它的作品,但我第一次运行它,我得到一个停顿,就像是挂在邮件项目窗口约45秒。一旦它得到过去的是,它的运行速度非常快的我让Outlook打开的时间休息。如果我关闭Outlook虽然,那么下一次我重新打开它,并发送一条消息,我会再有这样的期待。

任何想法,人民?

下面是我的外接代码:

namespace OutlookAttacher
{
    public partial class ThisAddIn
    {
        private void ThisAddIn_Startup(object sender, System.EventArgs e)
        {
            this.Application.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
        }

        private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
        {
        }

        void Application_ItemSend(object Item, ref bool Cancel)
        {
            if (Item is Microsoft.Office.Interop.Outlook.MailItem)
            {
                Microsoft.Office.Interop.Outlook.MailItem currentItem = Item as Microsoft.Office.Interop.Outlook.MailItem;
                Cancel = true;

                if (currentItem.Body.Contains("attach"))
                {
                    if (currentItem.Attachments.Count > 0)
                    {
                        Cancel = false;
                        //MessageBox.Show("This message will be sent now.");
                        currentItem.Send();
                    }
                    else
                    {
                        DialogResult ans = MessageBox.Show("This message has no attachments. Are you sure you want to send it?", "OutlookAttacher", MessageBoxButtons.YesNo);
                        if (ans.Equals(DialogResult.Yes))
                        {
                            Cancel = false;
                            //MessageBox.Show("This message will be sent now.");
                            currentItem.Send();
                        }
                    }
                }
                else
                {
                    Cancel = false;
                    //MessageBox.Show("This message will be sent now.");
                    currentItem.Send();
                }
            }
        }
    }
}

用于改进代码的任何建议,欢迎为好,因为这是我在Outlook加载第一刺

更新:我在5年的戴尔笔记本电脑在运行此,2 GB RAM和我鸵鸟政策,知道,英特尔的CPU。我喜欢添加跟踪/调试它的想法。我将不得不弄清楚如何通过代码,所以我可以看到它可能会花费最长的时间。感谢你们!

有帮助吗?

解决方案

OK,我真的很尴尬。我看到的延迟只是展望synching我的Exchange服务器。我在家的时候我测试和Outlook仍然通过HTTP连接。我看到今天工作速度快,在办公室里,所以没有HTTP。感谢反正答复。

: - )

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top