The email message cannot be sent .make sure the email has a valid recipient

and got an exception “The email message cannot be sent .make sure the email has a valid recipient“.

The reason is the ClientContext, you are passing to the function. Make sure the sharepoint site with which you created the Client Context has the Mail Recipient listed in the All People Group. To check that,