You need to sign in to do that
Don't have an account?

Row Lock issue on SendEmail ?
I'm using the Messaging.sendEmail function in Apex. How can I get a Row Lock issue from the sendEmail fonction ??
=> First error: SendEmail failed. First exception on row 0; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: []
This is very strange ...
=> First error: SendEmail failed. First exception on row 0; first error: UNABLE_TO_LOCK_ROW, unable to obtain exclusive access to this record: []
This is very strange ...
ROW_LOCK issue is very common if you have multiple users updating the record at the same time .
Or say a batch job is running and is updating a record and same record another trigger or code snippet (usually a future method) is updating.
Account [] accts = [SELECT Id FROM Account LIMIT 2 FOR UPDATE];
Using FOR UPDATE keyword helps to achieve a lock a client end to prevent this locking issues .
Here is a small article on sharing model to avoid this granular locking
https://help.salesforce.com/apex/HTViewSolution?urlname=How-can-I-avoid-getting-lock-errors-in-my-organization-1327109108393&language=en_US
http://blogs.developerforce.com/engineering/2013/01/reducing-lock-contention-by-avoiding-account-data-skews.html
Also read on data skews which may be another cause .
Thanks,
Abhishek
Messaging.sendEmail function
It' s not an specific error to Messaging.sendEmail function,
Generally what happens is that when you are sending an email, parallely there is some other action that is performing at the same time on the record which is causing the Lock row.
Log a case with support so that they can check the backend logs based on the time frame that you have received the error so that they can explain you what is causing the issue (I mean what other action is being performed which is causing the lock at the same time)