Monday, May 9, 2016

Operation is not valid due to current state of the object -- Elevated Privileges


Message=Operation is not valid due to the current state of the object.


I tried to call SPUtility.SendEmail within the RunWithElevatedPrivileges delegate.


If i try to run this method out of Elevated delegate, it works fine. All the other things that are working fine in Elevated Privileges (except send email) are,

  1. SPUtility.GetPrincipalsInGroup
  2. spWeb.EnsureUser


I found two solution/Work arounds ,

  1. Remove elevation (Do not know why this option works).
  2. Set HttpContext.Current to null. Following is the detail discussion over why this option works.

No comments:

Post a Comment