How to alter body of contact form? When submitting a message in my site contact form in Drupal 8.x
I have printed a message  

print_r($message['body'][1]);die;  //in my modulename_mail_alter(&amp;$message)


I get the following message 

Drupal\Core\Render\Markup Object
(
    [string:protected] =&gt; Message



   Test Message






     First Name
               Rahul



     Last Name
               gaikwad

)


How can I change the body content of the email.
Alter how exactly? You can cast the markup object to a string, then you can change the string or completely replace it.

Also check out the default integration that the contact_storage module has with swiftmailer to allow sending mails as HTML. That might get you much further than trying to change this string.