MS CRM 2011: Strange error during sending of an email from plugin

I had scenario when my plugin based on some condition had to send an email. I developed plugin, deployed it to server and during the testing I have got quite strange error:

Message was generic and hasn’t explained what happened. I’ve downloaded log file which had following text:

This log also didn’t explaine anything and I went to Trace:

I understood that this specific exception was generated not with my code but with CRM core operation – Sending of am email. I remain that about a year ago I faced and solved similar issue with tasks.

My habit is to instantiate IOrganizationService in plugins using system account:

I have changed instantiation of service to running user and everything worked without any issues:

I hope that this topic will help other developers to solve their issue faster then I solved it.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.