Outlook Add In - Hook into delete event without having to open the email.

Is it possible to hook into the BeforeDelete command without having to open the email to fire the event. At present my code will hit the BeforeDelete event when the email is open and delete is selected, but it does not fire if deleting without opening
the email.

Below is the Property MailItem I have in a class called MailItemContainer:
/// <summary>/// Gets or sets the Mail Item property/// </summary>public Outlook.MailItem MailItem
            get
                returnthis.mailItem;
            set
                if (this.mailItem != null)
                    try
                        ((Outlook.ItemEvents_10_Event)this.mailItem).Forward -= new Outlook.ItemEvents_10_ForwardEventHandler(this.MailItem_Reply);
                        ((Outlook.ItemEvents_10_Event)this.mailItem).Open -= new Outlook.ItemEvents_10_OpenEventHandler(this.MailItem_Open);
                        ((Outlook.ItemEvents_10_Event)this.mailItem).PropertyChange -= new Outlook.ItemEvents_10_PropertyChangeEventHandler(this.MailItem_PropertyChange);
                        ((Outlook.ItemEvents_10_Event)this.mailItem).Reply -= new Outlook.ItemEvents_10_ReplyEventHandler(this.MailItem_Reply);
                        ((Outlook.ItemEvents_10_Event)this.mailItem).ReplyAll -= new Outlook.ItemEvents_10_ReplyAllEventHandler(this.MailItem_Reply);
                        ((Outlook.ItemEvents_10_Event)this.mailItem).Send -= new Outlook.ItemEvents_10_SendEventHandler(this.MailItem_Send);
                        ((Outlook.ItemEvents_10_Event)this.mailItem).Unload -= new Outlook.ItemEvents_10_UnloadEventHandler(this.MailItem_Unload);
                        ((Outlook.ItemEvents_10_Event)this.mailItem).BeforeDelete -= new Outlook.ItemEvents_10_BeforeDeleteEventHandler(this.MailItem_Delete);
                    catch
                if (value != null && !value.Equals(this.mailItem))
                    this.mailItem = value;                    
                    ((Outlook.ItemEvents_10_Event)this.mailItem).Close += new Outlook.ItemEvents_10_CloseEventHandler(this.MailItem_Close);
                    ((Outlook.ItemEvents_10_Event)this.mailItem).Forward += new Outlook.ItemEvents_10_ForwardEventHandler(this.MailItem_Reply);
                    ((Outlook.ItemEvents_10_Event)this.mailItem).Open += new Outlook.ItemEvents_10_OpenEventHandler(this.MailItem_Open);
                    ((Outlook.ItemEvents_10_Event)this.mailItem).PropertyChange += new Outlook.ItemEvents_10_PropertyChangeEventHandler(this.MailItem_PropertyChange);
                    ((Outlook.ItemEvents_10_Event)this.mailItem).Reply += new Outlook.ItemEvents_10_ReplyEventHandler(this.MailItem_Reply);
                    ((Outlook.ItemEvents_10_Event)this.mailItem).ReplyAll += new Outlook.ItemEvents_10_ReplyAllEventHandler(this.MailItem_Reply);
                    ((Outlook.ItemEvents_10_Event)this.mailItem).Send += new Outlook.ItemEvents_10_SendEventHandler(this.MailItem_Send);
                    ((Outlook.ItemEvents_10_Event)this.mailItem).Unload += new Outlook.ItemEvents_10_UnloadEventHandler(this.MailItem_Unload);
                    ((Outlook.ItemEvents_10_Event)this.mailItem).BeforeDelete += new Outlook.ItemEvents_10_BeforeDeleteEventHandler(this.MailItem_Delete);
        }I have an Outlook AddIn which code is below:/// <summary>
/// Mutex to control loading and new mails
/// </summary>
private System.Threading.Mutex mutexLoad = new System.Threading.Mutex();
/// <summary>
/// Gets or sets the mail item list
/// </summary>
internal List<MailItemContainer> MailItemList
    get;
    set;
/// <summary>
/// Checks the list to see if the item has already been registered.
/// </summary>
/// <param name="findItem">The <typeparamref name="Outlook.MailItem">MailItem</typeparamref> to find.</param>
/// <returns><c>True</c> if found, <c>False</c> if not</returns>
public bool ContainsMailItem(Outlook.MailItem findItem)
    var found = false;
    foreach (var item in this.MailItemList)
        found = item.MailItem != null && item.MailItem.Equals(findItem);
        try
            found = found || (!string.IsNullOrWhiteSpace(item.MailItem.EntryID) && item.MailItem.EntryID.Equals(findItem.EntryID));
        catch
        if (found)
            break;
    return found;
/// <summary>
/// Finds the container for the mailitem in the list if the item has already been registered.
/// </summary>
/// <param name="findItem">The <typeparamref name="Outlook.MailItem">MailItem</typeparamref> to find.</param>
/// <returns>The MailItemContainer object that is used to extend the mail item</returns>
public MailItemContainer FindMailItem(Outlook.MailItem findItem)
    MailItemContainer mailContainer = null;
    foreach (var item in this.MailItemList)
        if (item.MailItem != null)
            if (item.MailItem.Equals(findItem))
                mailContainer = item;
            else
                try
                    if (!string.IsNullOrWhiteSpace(item.MailItem.EntryID) && item.MailItem.EntryID.Equals(findItem.EntryID))
                        mailContainer = item;
                catch
            if (mailContainer != null)
                break;
    return mailContainer;
/// <summary>
/// This will attempt to get the default values for the user and bind to the outlook events.
/// </summary>
private void InitialiseAddIn()
    var success = DA.SQLDataSource.IsDBConnectionValid();
    if (success)
        Utility.UserUpdated -= new EventHandler(this.Utility_UserUpdated);
        try
            Utility.User = DA.User.GetUserByUserId(Utility.UserId.GetValueOrDefault());
            success = Utility.User != null;
            if (success)
                Utility.Department = Utility.User.Department;
                success = Utility.Department != null;
                if (success)
                    this.MailItemList = new List<MailItemContainer>();
                    // Add a handler when an email item is opened
                    this.Application.ItemLoad += new Outlook.ApplicationEvents_11_ItemLoadEventHandler(this.ThisApplication_ItemLoad);
                    // Add a handler when an email item is new
                    this.Application.NewMailEx += new Outlook.ApplicationEvents_11_NewMailExEventHandler(this.ThisApplication_NewMailEx);
                    // Add a handler when the selection changes
                    this.Application.ActiveExplorer().SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(this.ThisAddIn_SelectionChange);
                else
                    MessageBox.Show("Your department has not been selected. Click on the \"Call Centre\" option on the menu and press the \"Settings\" button to select your department.", "PSP Call Centre Tracker");
            else
                MessageBox.Show("Your user profile has not been set up yet. Click on the \"Call Centre\" option on the menu and press the \"Settings\" button to select your department and create a profile.", "PSP Call Centre Tracker");
        catch
            MessageBox.Show("Call Centre Tracker was unable to communicate with active directory.\nTracking will not be enabled for this Outlook session.", "PSP Call Centre Tracker");
    else
        MessageBox.Show("Call Centre Tracker was unable to communicate with database.\nTracking will not be enabled for this Outlook session.", "PSP Call Centre Tracker");
    Utility.UserUpdated += new EventHandler(this.Utility_UserUpdated);
/// <summary>
/// The event that fires when the add-in is loaded
/// </summary>
/// <param name="sender">The object that fired the event</param>
/// <param name="e">The evetn args</param>
private void TrackingAddIn_Startup(object sender, System.EventArgs e)
    this.InitialiseAddIn();
/// <summary>
/// This fires when the add-in is closed
/// </summary>
/// <param name="sender">The ibject that fired the event</param>
/// <param name="e">The event args</param>
private void TrackingAddIn_Shutdown(object sender, System.EventArgs e)
    this.Application = null;
/// <summary>
/// Handles the event when the User has been changed.
/// </summary>
/// <param name="sender">The object that raised the event</param>
/// <param name="e">The default event arguments</param>
private void Utility_UserUpdated(object sender, EventArgs e)
    this.InitialiseAddIn();
/// <summary>
/// This is the application_ item load.
/// </summary>
/// <param name="item">The mail item.</param>
private void ThisApplication_ItemLoad(object item)
    if (item is Microsoft.Office.Interop.Outlook.MailItem)
        Outlook.MailItem mailItem = item as Outlook.MailItem;
        try
            this.mutexLoad.WaitOne();
            if (mailItem != null && !this.ContainsMailItem(mailItem))
                this.MailItemList.Add(new MailItemContainer(mailItem, this));
        finally
            this.mutexLoad.ReleaseMutex();
/// <summary>
/// Thises the application_ new mail ex.
/// </summary>
/// <param name="entryIDCollection">The entry ID collection.</param>
private void ThisApplication_NewMailEx(string entryIDCollection)
    var idCollection = entryIDCollection.Split(',');
    var sentFolder = this.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderSentMail);
    var inboxFolder = this.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
    foreach (var entryId in idCollection)
        var item = this.Application.Session.GetItemFromID(entryId);
        if (item is Outlook.MailItem)
            var mailItem = item as Outlook.MailItem;
            var parentFolder = Utility.GetTopLevelFolder(mailItem);
            if (parentFolder != null && parentFolder.EntryID == inboxFolder.EntryID)
                var referenceCode = Utility.MatchSubjectReference(mailItem.Subject);
                try
                    this.mutexLoad.WaitOne();
                    var containerItem = this.FindMailItem(mailItem);
                    if (!DA.TrackingItem.ExistsByReferenceCode(referenceCode, mailItem.ReceivedTime))
                        if (containerItem == null)
                            containerItem = new MailItemContainer(mailItem, this);
                            this.MailItemList.Add(containerItem);
                        containerItem.IsNewItem = true;
                        containerItem.TrackingItem = Utility.RegisterMailIncoming(item as Outlook.MailItem, this.Application);
                finally
                    this.mutexLoad.ReleaseMutex();
    ////Insert into Detail file and get the refence number
    ////MailInsert("Incoming");
/// <summary>
/// This action fires when the selection changes
/// </summary>
private void ThisAddIn_SelectionChange()
    var unread = this.MailItemList.Where(d => d.IsNewItem && d.MailItem.UnRead).ToList();
    foreach (var item in unread)
        item.DoUnReadCheck();

Similar Messages

  • How can I change the settings on my iPhone 5 so that I get new emails automatically? Without having to open the mail app.

    How can I change the settings on my iPhone 5 so that I get new emails automatically? Without having to open the mail app.
    Thanks!

    No, they will all follow the default setting. If you want them all to fetch, for example every 15 minutes, then set it to 15 minutes in Fetch. I only mentioned the other if you wanted to leave one for manual. I have an account on my phone that is a POP account that I get mail at home from. I let my home computer get this mail, but when I am out of town, I pick it up with the iPhone. That one is set to manual.

  • I have to save emails from outlook to my hard drive. When I go to open the email on the HD the attachment is not an attachment anymore. It needs to be. Help?

    My office uses outlook for emails, calendaring, etc. We save as all emails to a specific client related file for easy access and to reduce the items saved in outlook.
    Many of the emails have attachments. I use Firefox (love it) as my browser so when I save as an email it saves it with the Firefox Icon instead of the Outlook Envelope Icon. When I open the email from my computer (not outlook) the attachment name is there but it is not accessible. I have to go to the email in outlook and save the attachment(s) separately in order to access them. I don't want to do that. It takes up to much time and often the attachments are related to the data within the email and they need to be together in their original form.
    If I use Internet Explorer (which I hate) as my browser this does not happen. Can you help me? I really don't want to use IE.
    Thank you.

    I might be able to experiment with this a little.
    Are you running a recent version of Outlook Web App (i.e., Exchange 2010)?
    When you save files using IE, what format are they in (e.g., EML, RTF, HTML)?

  • How can i copy multiple projects that reference one event without having to duplicate the event over and over for each project?

    Each project has compound and regular media in them, and every time i attempt to duplicate the projects and have them reference one event on the new drive the rest of my media shows up missing and will not reconect. Wondering if anyone has had to tackle this problem. I have a limited amount of space on my Drobo thunderbolt drives and need to optomize it. Thank you

    So i called apple and after a few hours on the phone and them taking control of my computer they pretty much told me they had never seen this before and were sorry they couldnt assist in any way. The long explination is that i work for a company that films their footage in one long take and then sends it to me to cut into segments, i then have to copy these small edits which are all in different projects and the one large event over to a new hard drive to give to a guy to put titles on and then send back to the company. when i do this copy of project final cut X forces me to also duplicate the event leaving me with "event" (fcp1) and so on depending on how many projects there are. When i dont duplicate event and project together the whole project shows up as missing media and final cut X does not recognize that the original footage is being lost and therefor i am not even given the oportunity to reconect media. I have tried all conventional ways of copying and transfering and have an extensive background in editing and have never come across this, but then again this is final cut X and something that i try and stray away from if i have a choice in systems.
    to answer Tony im using copy project and event because it is the only option that works (copy project and used media works as well but only creates more confusion with having to rename files) I would prefer to be able to just copy the first project and event and then be able to source the rest of the project files from the first event i copied over.

  • When I access the address book, how can I copy an address without having to open the person's info in the edit window?

    When I find a person's address in the address book and highlight their name in one pane, in the lower pane their info shows up. Unfortunately, highlighting the information I want is disabled. So, I open their info in the edit window, and then click on the appropriate tab.
    Getting a single piece of information is not so inconvenient, but when you're putting together lists it is rather onerous to do it that way.
    Being able to highlight and copy off the address book panes would be cool. Thanks

    In an earlier communication, I had said that this was possible, at least with TB on Windows, but I realize now that it's only possible when a certain add-on is enabled: [https://freeshell.de//~kaosmos/morecols-en.html MoreFunctionsForAddressBook]
    http://chrisramsden.vfast.co.uk/3_How_to_install_Add-ons_in_Thunderbird.html
    Install the add-on, and see if you can now highlight info in the Contact Pane by dragging the cursor. Ctrl-C (or the Mac equivalent) to copy the highlighted text to the clipboard.
    You may notice that right-clicking an address in the Contact Pane now shows a Copy command, but a bug in the add-on prevents this option from being active.

  • How do you select multiple recipients without having to open the contacts list each time

    Just upgraded to Yosemite...not really impressed with the overall look but...can live it.  Using mail, if you did not want to send to an entire group, you could scroll through and select all the desired addresses at one time.  Now it appears that you have to click on the "plus sign", select one address, have it close then repeat the same process over and over.  Sorry, not an improvement if this is the way it is designed to work.   Any ideas on how to do this?
    Thanks for any help.

    Thanks for the input.  I am not sure why they changed the old system....is there any way to force the contact box to stay open?  Not being able to scroll down a list and select multiple selections is a big step back.  Hopefully Apple will get the message. 

  • How do you display thumbnails in pdf files without having to open the file?

    i used ot be able to see them in teh file folder before we got windows 7. We use CS4 and reader XI

    Zip (compress) the folder before you send it.

  • Updating sublinks without having to open the "subfiles"

    It would be great to have a way of updating sublinks (I use a lot of items that have linked items that themselves have linked items).  If one of those sub-sublinks is modified, I have to open all the files in question to update them.  It would be great to be able to do this from the parent file in the link panel.
    Thanks

    It's a long time this message has been posted... is there anyone here?
    I'm searching for an answer to this question too.
    Is there something new about it?
    Thanks

  • I want to be able to open my favorite bookmarks without having to open firefox first

    When I had IE 9 I could send my favorites to a "tab" in the lower right hand corner called Links and I could open any one of my favorites without opening IE first. When I want to open a favorite bookmark from Firefox, I have to open Firefox first. Is there a way to save bookmarks without having to open the webpage first?

    The usual method may be to open Firefox with certain favourites as homepages, or to open Firefox with the tabs from the last session. It may be unusual to have 20-30 pages as a homepage. There may be some limit to the string length but you could try it.
    *[[How to set the home page]]
    Once Firefox is open you may also choose to open any folder in the bookmarks library and use the option open all tabs. If you wanted you could also open Firefox directly into the library as a tab.
    * use ''chrome://browser/content/places/places.xul''
    Additionally note that firefox handles tab groups (I seem to recall development of this feature has stopped and it may be replaced in the future)
    * [[Use Tab Groups to organize a lot of tabs]]
    *[[Mastering the Tab Group Editor]]
    If you do use tab groups please note they are not too robust. You could loose the sessions, it is a good idea to bookmark important tabs.
    Another workaround may be to use a document containing a list of the required links and open that document or a link from it with Firefox. I am not sure if there are any add-ons that do what you require, you could have a look.

  • HOW CAN I DELETE AN EVENT WITHOUT  HAVING TO SELECTING IT FROM THE LIBRARY?

    I have a big problem.
    I want to delete an entire event from my library because everytime I select it imovie freezes and then close itself up. So I have to re-open imovie again. And when I want to select that particular event again the same problem occures. So I can not select that particular event. Therefore I can take NO action on this event.
    HOW CAN I DELETE AN EVENT WITHOUT HAVING TO SELECTING IT FROM THE LIBRARY?
    (Everytime I select it imovie closes itself up)
    All other events work fine. I believe The footage had a problem from capturing. but now it's in my computer and i can't open it.
    Please help me, I don't need this event, I can't open it therefore I can't use it and it takes place on my hardrive for nothing.
    Thank you

    One can delete it from one's computer. In the finder go to homeuser, movies, imovie events, delete the footage.
    Then reopen iMovie and see if that helps.
    Hugh

  • How can I make albums from events then delete events without deleting the album?

    Hey, just need a little help!
    How can I make albums from events then delete events without deleting the album?
    Many thanks

    You'll be more likely to get help with this if you ask in the iPhoto forum:
    https://discussions.apple.com/community/ilife/iphoto
    You'll need to tell people what version of iPhoto you have so they can give you correct advice.
    Regards.

  • Since switching to Yosemite, I am unable to paste any information into calendar events, instead having to type out all info such as location, notes, etc.  This is true both in daily view and weekly/monthly views as well.  Help?

    Since switching to Yosemite, I am unable to paste any information into calendar events, instead having to type out all info such as location, notes, etc.  This is true both in daily view and weekly/monthly views as well.  Help?

    You welcome

  • 0 down vote favorite        I would like to ask the following question. I am using mac os x 10.9 maverics me quicktime player version 10.3. Can I trim a video recording without having to press the pause or save it as a file? Or can I add a new recording t

    0 down vote  favorite  
    I would like to ask the following question. I am using mac os x 10.9 maverics me quicktime player version 10.3. Can I trim a video recording without having to press the pause or save it as a file? Or can I add a new recording to a video file? Thanks in advance

    Well,
    I tried the "Internet Recovery" option and finally saw Mac OS X Mountain Lion's install page but after waiting 7 hours when I just thought its going to start installing, I got another progress bar with 36 hours remining time to download "Additional Components" then after progressing 2-3 hours, it shows "Unable to write installation something..., Contact Apple Care"
    Then I accidently rebooted the machine and now it seems Internet Recovery don't work anymore, it shows "support.apple.com - 40 something!" error, and finally when I tried to reboot using Recovery HD, I found it's gone as-well!
    To be honest, I don't know what to do now, I am and dissapointed... also I do not have any Apple Store nearby, there is an authorized country reseller almost 650/km far away from my residents and they even charges too high (like $250) for doing such repairs (as per phone conversation)
    If anyone have any idea or anything to help me with, please do share- I'd be eternally grateful!

  • Is there a way I can copy an auto signature automatically into my contacts without having to type a new contact myself?

    Is there a way I can copy an auto signature from an automatically into my contacts without having to type a new contact myself?

    You don't buy an unlocked phone. You buy a Verizon iPhone at full retail. I just did this myself last month. I paid full retail for the phone and activated it on my plan. This allowed me to get a new phone before I was eligible to upgrade and keep my unlimited data. I also got a good deal on trading in my iPhone 5.
    You can buy the phone through Verizon or through Apple. If you buy it through Apple, I'd suggest that you not have them activated but do that yourself by logging into your account on your computer.
    Best of luck.

  • Call an event without having a subscription!!!

    Hi !!!
    Can i call an event without having a subscription to it???
    If i can, how , please show me an example!!!
    How can i pass data between processes, and how can i access data of the events and puting them in atributes without using a XML function, please show me how!!!
    Can i have more than one subscription "LOCAL" to the same ITem type????
    What4s the use of "External" subscriptions???
    thanks!!

    Hi Nuno
    We actually ship a buisness event system demonstration with the Oracle Workflow product, called the Buyer-Supplier Demonstartion. You can get details of this demo - including the names of the PL/SQL files, from the Getting Started Whitepaper and from the Sample Process chapter in the Workflow Guide.
    You should go to the Workflow 2.6 Technical Information section of the 9iAS Integration website. There are Development Standards - including sample code - and whitepapers for you to look at.
    If you are still having issues, you could contact Oracle Consulting Services for further assistance (see http://otn.oracle.com/consulting/)
    Cheers
    Mark
    Hi !!!
    Can i call an event without having a subscription to it???
    If i can, how , please show me an example!!!
    How can i pass data between processes, and how can i access data of the events and puting them in atributes without using a XML function, please show me how!!!
    Can i have more than one subscription "LOCAL" to the same ITem type????
    What4s the use of "External" subscriptions???
    thanks!!

Maybe you are looking for

  • Hyperlink in obiee email reports

    Hi, Well I have a question on hyperlink in obiee dashboards. The requirement is to email obiee Report or dashboard with Hyperlink enabled on date column which opens up PDF from the server for that date. End user will not access obiee analytics at all

  • Application Express 3.0.1 Upgrade

    I am running Application Express 2.0.2.00.49 and the backend is Oracle 10.2.0.1.0 on Linux 32bit and 64bit 9.3 Susie Servers. I want to upgrade to the new 3.0.1 Application Express and wonder what steps or tricks there might be waiting for me when I

  • R12 Search on Supplier Bank Account Number

    Hi, We want to search our suppliers on the bank account number, which is stored at site level. But I'm missing the field Bank account number on the Suppliers Inquiry Page. Is is possible to add this field to the Suppliers inquiry page?

  • Background colour on menu div

    I've got a bit of a problem that has been driving me mad for the last 24 hours.  I have created a CSS rollover menu.  I have made the div that holds the menu the same width as my wrapper, 800 pixels.  I have created 4 rollover menu buttons, however t

  • Java.util

    Hello, I've been programming in java since about Christmas and everything was going (more or less) fine. A few weeks ago I left it for a while but then went back to it and saw that alot of my programmes that were working fine weren't working anymore.