none
Outlook 2010 - "You don't have appropriate permission to perform this operation."

    Question

  • Hi,

    I'm developing an addin for Outlook 2010 that basically needs to add an attachment to specific mail items when that mail item is opened, even if the mail was already sent.

    I was able to do that easily. The problem is that it doesn't work on embedded mail items. That is, if I open a mail message that is an attachment (type OlEmbeddedItem) of another message, I cannot add attachments to it. It basically throws:

    System.UnauthorizedAccessException was caught
    Message=You don't have appropriate permission to perform this operation.
    Source=Microsoft Outlook
    StackTrace:
    at Microsoft.Office.Interop.Outlook.Attachments.Add(Object Source, Object Type, Object Position, Object DisplayName)
    at Ferbritas.Office.Outlook.Common.Wrappers.Documents.ReadOnly.ReadOnlyProxyMailItemWrapper.CopyAttachmentToEmail(String tmpDir, MailItem dest, Attachment a) in D:\DATA\vs_workspaces\FBX\FBDOC\FBClient\FBOfficeOutlookCommon\Wrappers\Documents\ReadOnly\ReadOnlyProxyMailItemWrapper.cs:line 133
    InnerException:

    Those embedded messages' inspector displays "Read-Only" on it's title, so I suppose that it's related to that.

    Another strange thing is that, even if it doesn't allow us to add attachments, it allows changing its body...

    Any idea how to make that item temporarily writable (we don't want to save it with that new attachment, it's only for displaying while it's opened)?

     

    Best regards

    • Moved by Sue MosherModerator Wednesday, September 08, 2010 7:47 PM Outlook-specific, not VSTO question (From:Visual Studio Tools for Office)
    Wednesday, September 08, 2010 6:46 PM

Answers

  • When it's opened from the attachment it's placed as read-only in the Outlook secure temp folder. Explicitly save the attachment to the file system to the location of your choice and open the item from the file system and it won't be read-only.

    --
    Ken Slovak
    [MVP - Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007.
    Reminder Manager, Extended Reminders, Attachment Options.
    http://www.slovaktech.com/products.htm
     
     
    "João Brito" <=?utf-8?B?Sm/Do28gQnJpdG8=?=> wrote in message news:dd1b6b5c-3175-4bad-86f3-08cccd94c8cc...

    Hi,

    I'm developing an addin for Outlook 2010 that basically needs to add an attachment to specific mail items when that mail item is opened, even if the mail was already sent.

    I was able to do that easily. The problem is that it doesn't work on embedded mail items. That is, if I open a mail message that is an attachment (type OlEmbeddedItem) of another message, I cannot add attachments to it. It basically throws:

    System.UnauthorizedAccessException was caught
    Message=You don't have appropriate permission to perform this operation.
    Source=Microsoft Outlook
    StackTrace:
    at Microsoft.Office.Interop.Outlook.Attachments.Add(Object Source, Object Type, Object Position, Object DisplayName)
    at Ferbritas.Office.Outlook.Common.Wrappers.Documents.ReadOnly.ReadOnlyProxyMailItemWrapper.CopyAttachmentToEmail(String tmpDir, MailItem dest, Attachment a) in D:\DATA\vs_workspaces\FBX\FBDOC\FBClient\FBOfficeOutlookCommon\Wrappers\Documents\ReadOnly\ReadOnlyProxyMailItemWrapper.cs:line 133
    InnerException:

    Those embedded messages' inspector displays "Read-Only" on it's title, so I suppose that it's related to that.

    Another strange thing is that, even if it doesn't allow us to add attachments, it allows changing its body...

    Any idea how to make that item temporarily writable (we don't want to save it with that new attachment, it's only for displaying while it's opened)?

     

    Best regards


    Ken Slovak MVP - Outlook
    • Marked as answer by Bessie Zhao Thursday, September 16, 2010 9:25 AM
    Thursday, September 09, 2010 1:01 PM
  • When I save the mail item in the filesystem and then I open it, the custom user properties are somehow lost (not sure if they are lost when it's being saved to the filesystem or when it's being opened from the filesystem).

    Is this a normal behaviour? Any idea why this happens?

    Yes, that's the normal behavior if the fields are not already defined in the store. See:

    Changes to custom properties in Outlook
    http://support.microsoft.com/?kbid=907985

    especially the section "Behavior changes in Outlook"

    • Marked as answer by Bessie Zhao Thursday, September 16, 2010 9:25 AM
    Thursday, September 09, 2010 2:57 PM

All replies

  • When it's opened from the attachment it's placed as read-only in the Outlook secure temp folder. Explicitly save the attachment to the file system to the location of your choice and open the item from the file system and it won't be read-only.

    --
    Ken Slovak
    [MVP - Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007.
    Reminder Manager, Extended Reminders, Attachment Options.
    http://www.slovaktech.com/products.htm
     
     
    "João Brito" <=?utf-8?B?Sm/Do28gQnJpdG8=?=> wrote in message news:dd1b6b5c-3175-4bad-86f3-08cccd94c8cc...

    Hi,

    I'm developing an addin for Outlook 2010 that basically needs to add an attachment to specific mail items when that mail item is opened, even if the mail was already sent.

    I was able to do that easily. The problem is that it doesn't work on embedded mail items. That is, if I open a mail message that is an attachment (type OlEmbeddedItem) of another message, I cannot add attachments to it. It basically throws:

    System.UnauthorizedAccessException was caught
    Message=You don't have appropriate permission to perform this operation.
    Source=Microsoft Outlook
    StackTrace:
    at Microsoft.Office.Interop.Outlook.Attachments.Add(Object Source, Object Type, Object Position, Object DisplayName)
    at Ferbritas.Office.Outlook.Common.Wrappers.Documents.ReadOnly.ReadOnlyProxyMailItemWrapper.CopyAttachmentToEmail(String tmpDir, MailItem dest, Attachment a) in D:\DATA\vs_workspaces\FBX\FBDOC\FBClient\FBOfficeOutlookCommon\Wrappers\Documents\ReadOnly\ReadOnlyProxyMailItemWrapper.cs:line 133
    InnerException:

    Those embedded messages' inspector displays "Read-Only" on it's title, so I suppose that it's related to that.

    Another strange thing is that, even if it doesn't allow us to add attachments, it allows changing its body...

    Any idea how to make that item temporarily writable (we don't want to save it with that new attachment, it's only for displaying while it's opened)?

     

    Best regards


    Ken Slovak MVP - Outlook
    • Marked as answer by Bessie Zhao Thursday, September 16, 2010 9:25 AM
    Thursday, September 09, 2010 1:01 PM
  • Hello,

    That should be a good solution, and I already tried it. But I ran into another problem:

    When I save the mail item in the filesystem and then I open it, the custom user properties are somehow lost (not sure if they are lost when it's being saved to the filesystem or when it's being opened from the filesystem).

    Is this a normal behaviour? Any idea why this happens?

    Best regards

    João Brito

    Thursday, September 09, 2010 2:46 PM
  • When I save the mail item in the filesystem and then I open it, the custom user properties are somehow lost (not sure if they are lost when it's being saved to the filesystem or when it's being opened from the filesystem).

    Is this a normal behaviour? Any idea why this happens?

    Yes, that's the normal behavior if the fields are not already defined in the store. See:

    Changes to custom properties in Outlook
    http://support.microsoft.com/?kbid=907985

    especially the section "Behavior changes in Outlook"

    • Marked as answer by Bessie Zhao Thursday, September 16, 2010 9:25 AM
    Thursday, September 09, 2010 2:57 PM
  • Hello,

    I don't know how can I register those fields in the store. That isn't obvious in that article. I would expect that information to go on the Form Manifest or something like that (just like custom actions), but there are no way to add UserProperties definitions there.

    Regards

    Thursday, September 09, 2010 6:43 PM
  • The article references quite a few methods of creating the fields in the store. Perhaps the simplest as you have code anyway, assuming you know which UserProperties are needed, is to use the UserProperties.Add() method to add the properties both to an item and a folder.

    --
    Ken Slovak
    [MVP - Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007.
    Reminder Manager, Extended Reminders, Attachment Options.
    http://www.slovaktech.com/products.htm
     
     
    "João Brito" <=?utf-8?B?Sm/Do28gQnJpdG8=?=> wrote in message news:0e902d72-ab72-42f6-8b69-454ca8ab7726...

    Hello,

    I don't know how can I register those fields in the store. That isn't obvious in that article. I would expect that information to go on the Form Manifest or something like that (just like custom actions), but there are no way to add UserProperties definitions there.

    Regards


    Ken Slovak MVP - Outlook
    Thursday, September 09, 2010 8:01 PM
  • But this doesn't apply to Office 2010?

    Is there any new version for this article?

     

    Regards

    Monday, September 13, 2010 9:27 AM
  • It applies to Outlook 2010 also. Just because a KB article hasn't been specifically updated doesn't mean it doesn't apply to a newer version of Outlook.

     


    Ken Slovak MVP - Outlook
    Monday, September 13, 2010 1:01 PM