Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VSTO Outlook ItemSend with C#

Tags:

c#

vsto

outlook

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

like image 684
Esteban Lopez Avatar asked Nov 15 '10 16:11

Esteban Lopez


1 Answers

Sorry...

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

If someone have this same issue, now you know

like image 63
Esteban Lopez Avatar answered Oct 16 '22 01:10

Esteban Lopez