office-interopoutlook-addinadd-inoffice-addinsaddin-express

How to identify that the MailItem opened in the Inspector is an attachment to another MailItem?


I need to identify if the selected 'MailItem'(Inspector or Explorer) is an attachment of another MailItem. I've done a lot of research and I have not identified any way to do that. I need to identify if it is an attachment of another message because I would like to edit the body of the message and save those changes. But if it's an attachment I can not change the body of the message.


Solution

  • Since the MailItem is being opened from an attachment, it will be read-only, according to this link. So, you can try to get the property PR_ACCESS_LEVEL from the MailItem, like this:

    object accessLevel = mailItem.PropertyAccessor.GetProperty("http://schemas.microsoft.com/mapi/proptag/0x0FF70003");
    

    According to this link, it will return: