private void ThisAddIn_Startup(object sender, System.EventArgs e) { this.Application.NewMail += new Microsoft.Office.Interop.Outlook .ApplicationEvents_11_NewMailEventHandler(ThisApplication_NewMail); } private void ThisApplication_NewMail() { Outlook.MAPIFolder inBox = this.Application.ActiveExplorer() .Session.GetDefaultFolder(Outlook .OlDefaultFolders.olFolderInbox); Outlook.Items inBoxItems = inBox.Items; Outlook.MailItem newEmail = null; inBoxItems = inBoxItems.Restrict("[Unread] = true"); foreach (object collectionItem in inBoxItems) { newEmail = collectionItem as Outlook.MailItem; if (newEmail != null) { if (newEmail.Attachments.Count > 0) { for (int i = 1; i <= newEmail .Attachments.Count; i++) { newEmail.Attachments[1].Delete(); } } } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)