1
sendEmail = () => {
  window.open("mailto:support@example.com?subject=SendMail&body=Description");
};

return (
  <div className="App">
    <button
      type="button"
      className="btn btn-danger"
      onClick={this.sendEmail}
    >
      Send email
    </button>
  </div>
);

I wrote my code in ReactJs but I am getting the blank screen. Please help.

Keerthi
  • 21
  • 1
  • 10
  • Can you just use an [e-mail-link](https://developer.mozilla.org/en-US/docs/Learn/HTML/Introduction_to_HTML/Creating_hyperlinks#e-mail_links) `email to foo` instead of ` – Martin May 03 '21 at 12:01
  • What do you mean by 'redirecting to outlook'? Your react app is opend in the browser, when you click the email link your browser location does not change, but instead the default email client of the system should open. Not every system has outlook installed. – Martin May 03 '21 at 13:35

1 Answers1

1

I don't know why this doesn't work for you, I tested it and it works fine for me, but try using an anchor link instead, like this:

mailtoHref = "mailto:support@example.com?subject=SendMail&body=Description";

return (
  <div className="App">
    <a href={this.mailtoHref} className="btn btn-danger">
      Send email
    </a>
  </div>
);

Nojze
  • 604
  • 8
  • 12