JSX中的多行电子邮件正文

我正在尝试使用以下方式创建具有多行正文的电子邮件:


<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"双引号但没有运气。


慕哥6287543
浏览 123回答 1
1回答

潇潇雨雨

您必须对在mailto:URL中传递的参数进行编码。对于换行符,可以使用%0A:<a&nbsp;href="mailto:foo@example.com?body=First%20line%0Asecond%20line%0A%0ANew%20paragraph">your&nbsp;message&nbsp;here</a>为了不必手动执行此操作,可以使用encodeURIComponent():console.log(encodeURIComponent(`first linesecond lineparagraph`));
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript