我正在尝试使用以下方式创建具有多行正文的电子邮件:<a href={"mailto:" + this.state.emailsToNotify + "?subject=" + this.state.mname + "&body=Please, review: " + "\n" + this.state.mname + "\n" + "at " + emailBody }> <button style={button4TableStyleObject('#007a86', '#ebf5ff', '#ff3900 #ff3900')} >{'Notify Selected'} </button></a>但是,Outlook使用单行打开此电子邮件。有没有办法使它成为多行?我使用"\n"双引号但没有运气。
1 回答

潇潇雨雨
TA贡献1833条经验 获得超4个赞
您必须对在mailto:
URL中传递的参数进行编码。对于换行符,可以使用%0A
:
<a href="mailto:foo@example.com?body=First%20line%0Asecond%20line%0A%0ANew%20paragraph">your message here</a>
为了不必手动执行此操作,可以使用encodeURIComponent():
console.log(encodeURIComponent(`first line
second line
paragraph`));
添加回答
举报
0/150
提交
取消