none
VSTO After ItemSend event RRS feed

  • Question

  • Hi,

    I am looking for following information.

    is there any event that will fire immediately after  ItemSend ?

     Application.ItemSend += new Outlook.ApplicationEvents_11_ItemSendEventHandler(Application_MailItemSend);

    I have to do some work on that event.

    I am looking for something like   Application.AfterItemSend 


    Kind Regards

    Harish

    Tuesday, December 17, 2019 3:58 PM

Answers

  • There is no such event for one simple reason - message submission is asynchronous in Outlook: Application.ItemSend fires immediately prior to handing the message over to the spooler. This is your last chance to cancel the submission. After that, the spooler owns the message. The message can be submitted a millisecond later  or in a few hours (e.g. when the computer is reconnected to the network).

    The best you can do is the Items.ItemAdd event on the Sent Items folder.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by hmsn Wednesday, December 18, 2019 12:19 PM
    Tuesday, December 17, 2019 4:24 PM

All replies

  • There is no such event for one simple reason - message submission is asynchronous in Outlook: Application.ItemSend fires immediately prior to handing the message over to the spooler. This is your last chance to cancel the submission. After that, the spooler owns the message. The message can be submitted a millisecond later  or in a few hours (e.g. when the computer is reconnected to the network).

    The best you can do is the Items.ItemAdd event on the Sent Items folder.


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    • Marked as answer by hmsn Wednesday, December 18, 2019 12:19 PM
    Tuesday, December 17, 2019 4:24 PM
  • Thank you Dmitry for your response.

    Could you please have a quick look if anything wrong with following lines

    Outlook.NameSpace outlookNameSpace;
                outlookNameSpace = this.Application.GetNamespace("MAPI");
                Outlook.MAPIFolder sent;
                sent = outlookNameSpace.GetDefaultFolder(
                        Microsoft.Office.Interop.Outlook.
                        OlDefaultFolders.olFolderSentMail);
                Outlook.Items items;
                items = sent.Items;
                items.ItemAdd += new Outlook.ItemsEvents_ItemAddEventHandler(items_ItemAdd);

    I am unable to hit 

       void items_ItemAdd(object Item)

    Wednesday, December 18, 2019 12:00 PM
  • the items variable needs to be declared on the global (class) level so that it stays alive even after that method exits.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.5 is now available!

    Wednesday, December 18, 2019 1:55 PM