2

I'm using POP for mails and I want to inform one of my company mails when a message is sent by one of the users. And I want it hidden so they cannot delete it. I see there are solutions bun not free and not suitable for every version of Outlook.

Is there a short way to code it in c#, like an office add-in or else?

EDIT Here is an example I guess: VSTO Outlook ItemSend with C#

And here is the code:

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.BCC += ";Name Surname<name.surname@tld.com>";
        mail.Recipients.ResolveAll();
        mail.Save();
    }
}

This code worked couple times but now its not working.

Community
  • 1
  • 1
HasanG
  • 12,734
  • 29
  • 100
  • 154

1 Answers1

1

This blog post will help you.

Bottom line: hook the ItemSend event.

Randolpho
  • 55,384
  • 17
  • 145
  • 179
  • @HasanGürsoy Add-in Express is not necessary to hook the ItemSend event. Visual Studio is, of course. Is that what you're complaining about? – Randolpho Nov 22 '11 at 00:57