Javascript 电子邮件正文中的多行文本
我试图从dynamics crm(Phonecall实体)获得一些细节,并通过电子邮件将这些信息写入正文。问题是当“描述字段”中有多行时,所有文本都将在电子邮件正文中的一行中写入(见图)。有人能帮我吗?谢谢Javascript 电子邮件正文中的多行文本,javascript,http,Javascript,Http,我试图从dynamics crm(Phonecall实体)获得一些细节,并通过电子邮件将这些信息写入正文。问题是当“描述字段”中有多行时,所有文本都将在电子邮件正文中的一行中写入(见图)。有人能帮我吗?谢谢 您需要转义description,就像转义URL中的所有显式换行一样 连接时,不要对每个部分调用escape(),而是连接所有内容,然后对整个内容进行转义 您应该使用encodeURIComponent()而不是过时的escape() escape()已弃用,您应该使用encodeURICo
您需要转义
description
,就像转义URL中的所有显式换行一样
连接时,不要对每个部分调用escape()
,而是连接所有内容,然后对整个内容进行转义
您应该使用encodeURIComponent()
而不是过时的escape()
escape()
已弃用,您应该使用encodeURIComponent()
。
function TriggerOutlook()
{
//get the form value
var form=Xrm.Page.ui.getFormType();
//if the form is saved
if(form==2)
{
// get the end date
var scheduledend = Xrm.Page.getAttribute("actualend").getValue();
var date =scheduledend.toString();
var date_split = date.split(' ');
switch(date_split[1])
{
case "Jan":
var month="01";
break;
case "Feb":
var month="02";
break;
case "Mar":
var month="03";
break;
case "Apr":
var month="04";
break;
case "May":
var month="05";
break;
case "Jun":
var month="06";
break;
case "Jul":
var month="07";
break;
case "Aug":
var month="08";
break;
case "Sep":
var month="09";
break;
case "Okt":
var month="10";
break;
case "Nov":
var month="11";
break;
case "Dec":
var month="12";
break;
}
var end_Time=month+"/"+date_split[2]+"/"+date_split[3] ;
var sub=Xrm.Page.getAttribute("subject").getValue() ;
//get the description
var description = Xrm.Page.getAttribute("description").getValue();
//get the required Value
var required = Xrm.Page.data.entity.attributes.get("to").getValue();
//test of the empty fields
if (end_Time == null)
{
end_Time="";
}
if(description == null)
{
description="";
}
if( required==null || required=="")
{
required="";
}
else
{
var required_name=required[0].name;
var required_id=required[0].id.toLowerCase();
}
// trigger the Outlook
var subject=required_name+", "+ sub ;
var body = "End Time:" + end_Time + escape('\n') + "Account:" + required_name +escape('\n') + "Contact:" + escape('\n') + "Description:" + description;
window.location.href = "mailto:?body="+body+"&subject="+subject;
}
}
var subject = encodeURIComponent(required_name + ", " + sub);
var body = encodeURIComponent("End Time:" + end_Time + '\n' + "Account:" + required_name + '\n' + "Contact:" + '\n' + "Description:" + description);