FYI: Exchange 2007 OnSyncSave Store Events and Plain Text Message Don’t Play Nice
…Recently, I worked with a customer who was facing the problem described below. We requested a fix but ended up finding a workaround using a Transport Agent. At this time there is no plan to fix this issue in Exchange 2007…
In an OnSyncSave store event in Exchange 2007 every field's value of a plain text message which triggers the event returns the following exception in the first pre-commit event:
"Operation failed to complete and the status is unavailable. The field may be unavailable or the operation was not attempted."
When the OnSyncSave event fires again for this message after the message has been committed to the store the property values can be read.
NOTE: HTML and RTF messages do not have this problem - this only applies to Plain Text messages.
There are no straight forward workarounds, only other options which may or may not suit your application’s needs:
- Use the OnSave asynchronous event sink. The trade off here is obvious but the OnSave event doesn’t have any problem reading properties from a message that triggers the event.
- Use a Transport Agent. The main trade off here is that transport agents operate outside of the mailbox in the transport stack. They can’t react to events that happen within a mailbox such as changing an item in the calendar or moving a message from one folder to another. They only react to mail being delivered to or sent from a mailbox.
- Use an Outlook Add-in. The big trade-off here is that changes in OWA are not handled, you can only react to events that the user triggers in Outlook.
- Use rules. The main drawback is that they have a fixed set of functions but they don’t require any code to be written or bits to be deployed.
Again, depending on your solution one of these workarounds or combination of two might accomplish what you need. An example of combining two of these options would be to use a transport agent to tag messages as they are sent to a particular mailbox and then use a rule to key off this tag and move those messages to a specific folder on deliver.