none
Outlook - Operation Aborted Exception when adding an attachment through Attachments.Add RRS feed

  • Question

  • We have an integration the handles Application ItemSend event, to perform extra processing on the attachments remove them using Attachment.Delete and potentially re-adding them after processing using Attachments.Add.

    We are experiencing an intermittent issue when adding attachments at different sites where programmatically adding an attachment fails with an Operation Aborted Exception. 

    We are unable to reproduce this reliably in the production environments where the issue is occurring, but I have been able to reproduce it by creating another AddIn that handles the BeforeAttachmentAdd event and setting cancel to true .

    I have a few questions I'd appreciate any help with.

    1) What are the possible causes of an Operation Aborted Exception when calling Attachments Add?

    2) Is there any way to trace which AddIns are handling specific events in Outlook or tracing any other interactions are occurring, as given the number of AddIns that are present and the different environments it's going to be time consumingto determine the cause in each environment.

    3)  When the Operation Aborted Exception is thrown is there any way of determining what caused this?

    In some cases we are able workaround this by using the PropertyAccessor to replace the content of the files - when the filename hasn't changed.
    Wednesday, October 3, 2018 3:36 PM

All replies

  • Hi Edward,

    >>1) What are the possible causes of an Operation Aborted Exception when calling Attachments Add?

    If you are adding the attachment programmatically by calling MailItem.Attachments.Add, would you not expect it to raise an exception since the Attachment object cannot be returned? If an exception is not raised, what would MailItem.Attachments.Add return? It cannot possibly be a valid attachment object since you explicitly disallowed the new attachment.

    Please refer to the link as below:

    Operation aborted (Exception from HRESULT: 0x80004004 (E_ABORT))

    >>2) Is there any way to trace which AddIns are handling specific events in Outlook or tracing any other interactions are occurring, as given the number of AddIns that are present and the different environments it's going to be time consumingto determine the cause in each environment.

    Base on my research, I'm afraid there is no good solution to achieve it. 

    Here is a solution to track of all mail events. For more information, please see the links as below:

    Which will keep track of all mail events like new mail, read, reply,forward and delete etc.

    How to handle Outlook item’s Reply event: tracking Inspector.Activate

    >>3)  When the Operation Aborted Exception is thrown is there any way of determining what caused this?

    Base on my research, I'm afraid there is no better solution to achieve it.

    Hopefully it helps you.

    Best Regards,

    Lina


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.



    • Edited by Lina-MSFT Thursday, October 4, 2018 6:39 AM
    Thursday, October 4, 2018 3:03 AM
  • Hi Lina,

    I meant what are the possible causes of an Operation Aborted Exception when adding an attachment? Is it just by setting cancel on the BeforeAttachmentAdd event, or are there other things that can cause an Operation Aborted Exception?

    thanks,

    Ed


    Friday, October 5, 2018 12:19 PM
  • Hi Edward,

    According to my experience,  it is currently possible causes of an Operation Aborted Exception when using the Attachment.Add method is to set cancel to true on BeforeAttachmentAdd event.

    We will do research for this. If you have any updates, please let us know.

    Best Regards,

    Lina


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Wednesday, October 10, 2018 6:44 AM
  • Hi Edward,

    Thanks for your asking. Please remember to mark the replies(Include your solution) as answers if they helped and please help us close the thread.

     

    Thank you for understanding. If you have any question, or update, please feel free to let us know.

     

    I wish you a happy life!

    Best Regards,

    Lina


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread.

    Monday, October 15, 2018 6:51 AM