我想在我的邮件正文中插入一个换行符。
我试了%0A, %0D和%0D%0A。对我来说什么都没用。
我在Gmail、Yahoo、Apple Mail、Outlook 2010、Outlook.com和Thunderbird上使用Mac OSX上的谷歌Chrome浏览器进行了测试。
有人帮忙吗?
这是我的代码:
<a href="mailto:email@mycompany.com?subject=Subscribe&body=Lastame%20%3A%0D%0A%20Firstname%20%3A"><img alt="Subscribe" class="center" height="50" src="subscribe.png" style="width: 137px; height: 50px; color: #4da6f7; font-size: 20px; display: block;" width="137"></a>
对于使用JavaScript的明文电子邮件,您也可以使用\r与encodeURIComponent()。
例如,这条消息:
hello\rthis answer is now well formated\rand it contains good knowleadge\rthat is why I am up voting
URI编码后,结果如下:
hello%0Dthis%20answer%20is%20now%20well%20formated%0Dand%20it%20contains%20good%20knowleadge%0Dthat%20is%20why%20I%20am%20up%20voting
并且,使用href:
mailto:me@house.country?body=hello%0Dthis%20answer%20is%20now%20well%20formated%0Dand%20it%20contains%20good%20knowleadge%0Dthat%20is%20why%20I%20am%20up%20voting
将导致以下电子邮件正文:
hello
this answer is now well formated
and it contains good knowleadge
that is why I am up voting
对于使用JavaScript的明文电子邮件,您也可以使用\r与encodeURIComponent()。
例如,这条消息:
hello\rthis answer is now well formated\rand it contains good knowleadge\rthat is why I am up voting
URI编码后,结果如下:
hello%0Dthis%20answer%20is%20now%20well%20formated%0Dand%20it%20contains%20good%20knowleadge%0Dthat%20is%20why%20I%20am%20up%20voting
并且,使用href:
mailto:me@house.country?body=hello%0Dthis%20answer%20is%20now%20well%20formated%0Dand%20it%20contains%20good%20knowleadge%0Dthat%20is%20why%20I%20am%20up%20voting
将导致以下电子邮件正文:
hello
this answer is now well formated
and it contains good knowleadge
that is why I am up voting
我建议您尝试html标签<br>,以防您的营销应用程序将识别它。
我使用%0D%0A。这应该工作,只要电子邮件是HTML格式。
<a href="mailto:email@mycompany.com?subject=Subscribe&body=Lastame%20%3A%0D%0AFirstname%20%3A"><img alt="Subscribe" class="center" height="50" src="subscribe.png" style="width: 137px; height: 50px; color: #4da6f7; font-size: 20px; display: block;" width="137"></a>
您可能想要去掉Firstname前面的%20,否则下一行的第一个字符将有一个空格。
注意,当我用您的代码测试这个时,它工作(以及一些额外的间距)。您使用的邮件客户端不支持HTML格式吗?