1

I am creating a web part in SharePoint Online using SPFx REACT framework and I want to open an email pop up with an HTML table in the body section of the email.

Currently, I am using mailto to open an email and I can see my HTML code in the body section of the email. Are there any ways in REACT/JavaScript/jQuery with which I can achieve this functionality?

Current code:

    let mailBody = `<table>
    <tr>
      <th>Company</th>
      <th>Contact</th>
      <th>Country</th>
    </tr>
    <tr>
      <td>Alfreds Futterkiste</td>
      <td>Maria Anders</td>
      <td>Germany</td>
    </tr>
    <tr>
      <td>Centro comercial Moctezuma</td>
      <td>Francisco Chang</td>
      <td>Mexico</td>
    </tr>
  </table>`;
    location.href = `mailto:myEmailID?subject=Hello&body=${mailBody}`;
1
  • Hi, does my below answer help you in any way? If yes, please Upvote(^) and accept as an Answer as it helped you & it will help others with similar question in future to find the correct answer easily. It also removes this question from "Unanswered questions" list. Commented Jun 8, 2023 at 8:58

1 Answer 1

1

It is not possible to add HTML tables in email body as you are using mailto which does not support using HTML in email body.

Section 2 of RFC 2368 says that the body field is supposed to be in text/plain format, so you can't do HTML.

Source:

  1. Is it possible to add an HTML link in the body of a MAILTO link [duplicate]
  2. mailto link with HTML body

You maybe able to add line breaks and other characters using ASCII code as shown in below article but you cannot add complete HTML table: HTML email links code – How to add a subject, body text and other cool stuff

2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.