VSTO Outlook ItemSend with C#

跟風遠走 提交于 2020-01-30 04:28:48

问题


I'm trying to add a string in the end of an Outlook email's body with VSTO

private void ThisAddIn_Startup(object sender, System.EventArgs e)
    {
        this.Application.ItemSend += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_ItemSend);
    }

    void Application_ItemSend(object Item, ref bool Cancel)
    {
        if (Item is Outlook.MailItem)
        {
            Outlook.MailItem mail = (Outlook.MailItem)Item;
            mail.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
            mail.Body += "My Sample Text";
            mail.Save();
        }
    }

When i run with F5 my code from VStudio, the app isn't stopping in my breakpoints and the emails do not contain the added line

What I can do about it?

Note: I'm working with VS2008 and Outlook 2007

Thanks in advance


回答1:


Sorry...

The problem was i've to close my outlook and restarted with F5.

If someone have this same issue, now you know



来源:https://stackoverflow.com/questions/4186277/vsto-outlook-itemsend-with-c-sharp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!