How custom event receivers affect OnePlaceMail upload process

Article describes inconsistent upload issues and ways of fixing them.

Issue

Library event receivers may affect the OnePlaceMail uploading process resulting in inconsistent errors.

 

Scenario 1

File has been modified error. There could be several problematic emails in the upload results window, but some of them are uploaded succesfully:

01 file has been modified

 

 

Scenario 2

Metadata was not populated. Some of the email messages left without email properties updated after uploading several emails:

02 metadata not populated

 

 

Reason

OnePlaceMail uploads an email message in several steps and some of them include the following events:

  1. ItemAdding - when msg or other file type is uploaded into library this event is triggered - occurs before added
  2. ItemAdded - when msg or other file type is uploaded into library this event is triggered - occurs after added
  3. ItemUpdating - we get the item again in library and apply the metadata to item so this event is triggered - occurs before metadata applied
  4. ItemUpdated - we get the item again in library and apply the metadata to item so this event is triggered - occurs after metadata applied

Any custom code written in these event handlers could cause an issue.

Library event receivers have one of the two synchronization types either Asynchronous or Synchronous.

Asynchronous event receivers are executed after committing the file to the database, thus it could happen before 3rd step of OnePlaceMail process (which leads to the error “The file has been modified” or doesn't allow OnePlaceMail to successfully update library columns).

It is highly dependent on the network and server speed; that is why this issue is not 100% reproducible.

For more information about event receivers synchronization type please refer to the following Microsoft KB article: SPItemEventReceiver methods

 

Solution

 

It's possible to use one of the email properties as a flag of OnePlaceMail has finished its job. E.g. custom event handlers should fire only after EmDateSent has been updated in the library.

Another option is to change synchronization method of the event receiver:

SharePoint 2007 and older versions

According to the SPEventReceiverDefinition Properties for WSS3 there is no property which allows to change synchronization method of the event receiver. To change the event receiver behaviour you could change it's type to make it synchronous (e.g. change type from ItemAdded to ItemAdding).

 

SharePoint 2010 and newer versions

If synchronization method of the event receiver is changed to  “Synchronous” then the event will fire before committing the file to the database thus not conflicting with OnePlaceMail process.

Posted in Configuration
Coping with COVID-19 : OnePlace Solutions is helping businesses impacted by COVID-19 and offering the OnePlaceMail App for free until June 30, 2020. Learn more