none
VSTO - Delete is not working RRS feed

  • Question

  • Delete() is not deleting the copy which was created

    Microsoft.Office.Interop.Outlook.MailItem mailItem = (selObject as Microsoft.Office.Interop.Outlook.MailItem);
    MailItem copy = mailItem.Copy();
    
    // Some functionality
    
    copy.Delete();

    Can you please help?

    Thanks, Amit

    Tuesday, December 11, 2018 12:27 PM

All replies

  • Hi there,

    Try saving the copy before deleting it, and then deleting the replica. Please refer to the following code:

    Microsoft.Office.Interop.Outlook.MailItem mailItem = (selObject as Microsoft.Office.Interop.Outlook.MailItem);
    MailItem copy = mailItem.Copy();
    copy.Save();
    
    // Some functionality
    
    copy.Delete();

    Please refer to the following link:

    Delete Outlook MailItem?

    Best Regards,

    Bruce


    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, December 12, 2018 3:53 AM
    Moderator
  • Hi there,

    This thread has been around for a long time. Please remember to mark the replies as answers if they helped. Please help us close the thread.

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

    I wish you a happy life!

    Best Regards,

    Bruce


    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, December 26, 2018 7:05 AM
    Moderator