0

I am converting Visualforce pages to Lightning Web Components. One element is a button that has as a target mailto:

What I am seeing: the mail client is started, with the proper To: value. But cc and body are empty. Even when I have a very simple mailto value:

mailto:nowhere@mozilla.org?cc=nobody@mozilla.org&subject=This%20is%20the%20subject

The only thing that is filled, is the To. Everything after the ? seems to be ignored. Under Classic it's working perfectly. Do I need to do something else?

Part of HTML:

<div class="slds-no-flex">
  <form action={replyToEmailLink}>
    <button type="submit" class="slds-button slds-button_neutral">
      {replyToEmailLabel}
    </button>
  </form>
</div>

Part of JS:

get replyToEmailLink() {
    return 'mailto:nowhere@mozilla.org?cc=nobody@mozilla.org&subject=This%20is%20the%20subject';
}

In the console I get a warning:

Mixed Content: The page at 'https://XYZ.lightning.force.com/lightning/r/Opportunity/0060C0000039cbDQAQ/view' was loaded over a secure connection, but contains a form that targets an insecure endpoint 'mailto:nowhere@mozilla.org?cc=nobody@mozilla.org&subject=This%20is%20the%20subject'. This endpoint should be made available over a secure connection.

But the link itself is working, I get a mail-compose window of my email client (Outlook).

1 Answer 1

3

The form action tag only accepts a url if you need to provide a query parameter you need to specify it as input element of hidden type

Example

<div class="slds-no-flex">
<form action={replyToEmailLink} method="GET">
  <input type="hidden" name="cc" value="nobody@mozilla.org" /> 
  <button type="submit" class="slds-button slds-button_neutral">
    Mail Me
  </button>
</form>

An even better approach is to just use an <a> tag

Example2

<lightning-card title="Mail Example">
      <a href={replyToEmailLink}>Mail me</a>
  </lightning-card>
1
  • Excellent, thanks! My link has to look like a buton, so I ended up with: <a class="slds-button slds-button_neutral" href={replyToEmailLink}>{replyToEmailLabel}</a> Mar 18, 2020 at 12:12

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .