Answered by:

Question

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:

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.

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:

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:

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.

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:

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).

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:

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.

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.

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.