Reputation: 13161
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. I want it hidden so they cannot delete it. There are solutions but 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?
Example: VSTO Outlook ItemSend with C#
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<[email protected]>";
mail.Recipients.ResolveAll();
mail.Save();
}
}
This code worked a couple of times but now it is not working.
Upvotes: 2
Views: 1287
Reputation: 66265
Do not add to the BCC property, use something like the following.
var recip = mail.Recipients.Add("\"Name Surname\"<[email protected]>");
recip.Type = OlMailRecipientType.olBCC;
recip.Resolve();
Upvotes: 0