1

The code block below, upon a button click, will open an email with the some text and a link that I dynamically generate in the body of the email. It all works how I want, except that the link is long and looks like gibberish to the person receiving the email of course.

Is it possible to have my mailto: have either alternate text like an HTML link would have? Or even a button instead of the linked printed out in full?

sendSurvey(employee, employeeId, employmentLevel, audit, client) {
    let stringEmployee = employee.replace(/ /g, "%20");
    stringEmployee = encodeURI(stringEmployee);
    let stringEmploymentLevel = employmentLevel.replace(/ /g, "%20");
    stringEmploymentLevel = encodeURI(stringEmploymentLevel);
    let stringClient = this.state.selectedClient;
    stringClient = stringClient.replace(/ /g, "%20");
    stringClient = encodeURI(stringClient);
    const link = `http://localhost:3000/hca-survey/${employeeId}/${stringEmployee}/${stringEmploymentLevel}/${this.state.selectedAudit}/${stringClient}`;

    const subject = `Human Capital Analysis - ${employee}`;
    
    const body = `Hello, ${employee}. ${client} has selected you to participate in our Human Capital Analysis survey. Please click the link below in order to complete the survey at your convenience.`;
    
    window.open(`mailto:?subject=${subject}&body=${body}
    
    %0D%0A%0D%0A${link}
    
    %0D%0A%0D%0AThank%20You%20for%20your%20responses...`);
  }
Adam Norton
  • 512
  • 2
  • 5
  • 21
  • No, unfortunately you can’t encode HTML in the body of a mailto link. Duplicate of https://stackoverflow.com/q/5620324/673457 – Ted Whitehead Mar 01 '21 at 20:05

0 Answers0