none
The property "http://schemas.microsoft.com/mapi/proptag/0x37010102" does not support this operation - Writing to attachment in OL2007 RRS feed

  • Question

  • I am trying to update the content of an email attachment from my VSTO Outlook add-in as follows (C#);

    Outlook.DocumentItem mailItem = this.NameSpace.GetItemFromID(entryId, storeId);
    Outlook.Attachments attachments = mailItem.Attachments;
    Outlook.Attachment attachment = attachments[1];
    Outlook.PropertyAccessor propertyAccessor = attachment.PropertyAccessor;
    
    byte[] newAttachmentData = File.ReadAllBytes(attachmentPath);
    propertyAccessor.SetProperty(PR_ATTACH_DATA_BIN, newAttachmentData);
    
    Marshal.ReleaseComObject(propertyAccessor);
    Marshal.ReleaseComObject(attachment);
    Marshal.ReleaseComObject(attachments);
    Marshal.ReleaseComObject(mailItem);

    This works fine in Outlook 2010, but in Outlook 2007, I get the following error;

    Caught exception: 'System.UnauthorizedAccessException: The property "http://schemas.microsoft.com/mapi/proptag/0x37010102" does not support this operation.

    I found this thread discussing this error message;

    http://social.msdn.microsoft.com/Forums/vstudio/en-US/3a190860-8dac-4a3d-b7d4-08bbcd27828c/byte-stream-from-mail-attachment-mapiobject

    However, in that thread Ken implied that the problem was only for reading, not writing;

        "So with PropertyAccessor in 2007 you can write larger properties but not read them back."
     
    As you can see from my code above, I am only trying to write, not read, yet I am still getting this error in 2007.

    Am I doing something wrong here?

    Thanks for your help,
    Chris
    Friday, October 11, 2013 2:01 PM

Answers

  • I don't think you are doing anything wrong - if I remember correctly, that is just an Outlook 2007 bug.

    The only workarounds are

    1. Completely removing the old attachment and adding it again

    2. Use Extended MAPI directly (C++ or Delphi)

    3. Redemption


    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 Chris McA Friday, January 3, 2014 3:06 PM
    Friday, October 11, 2013 6:36 PM

All replies

  • I don't think you are doing anything wrong - if I remember correctly, that is just an Outlook 2007 bug.

    The only workarounds are

    1. Completely removing the old attachment and adding it again

    2. Use Extended MAPI directly (C++ or Delphi)

    3. Redemption


    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 Chris McA Friday, January 3, 2014 3:06 PM
    Friday, October 11, 2013 6:36 PM
  • Hi Dmitry,

    I've mailed your private email address with some details on a problem that I encountered using Redemption in this circumstance. Let me know if what I've sent you is of any use to you - but if not then I can send you a complete add-in which demonstrates the problem.

    Regards.

    Chris

    Sunday, October 13, 2013 10:41 AM
  • When did you send your message? I don't think I received anything...

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

    Sunday, October 13, 2013 4:06 PM
  • When did you send your message? I don't think I received anything...

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

    I sent it on Friday afternoon to list AT dimastr DOT com - is that the correct email address?

    I'll resend it anyway - let me know if it comes through this time.

    Cheers,

    Chris

    Sunday, October 13, 2013 4:32 PM
  • I got your email this time..

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

    Sunday, October 13, 2013 7:58 PM