The highlighted headers in the mailObject above are required to specify the content type of the email as HTML. Without this header, the mail will be sent as a plain text and the HTML formatting is ignored.

Using this helper method

The above method can be used as a helper method to send mails from your client code or SharePoint Apps or Add-Ins. Make sure to include the required jQuery references