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

Ever tried to send emails using CSOM using

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,

Navigate to [Site_Url]/_layouts/15/people.aspx?MembershipGroupId=0

and make sure the Email To user is listed in the group.

For more info Refer this .

Activate Publishing features using CSOM

After scouring through the internet and some trial and error, here it is.

You can find the GUID for the feature here .