1

我制作了一个脚本,其中数据从谷歌电子表格发送到我没有创建新行或不支持换行命令的 WhatsApp。GAS 也不支持 \n 以及
拆分我的消息的声明。

if(data[i][4]!="")
        {
        var tempDate=new Date(data[i][4])
        tempDate.setDate(tempDate.getDate() - 55);
        var message1 = 'Dear '+data[i][13]+' '+data[i][12]+' '+data[i] 
[11]+' '
        message1+= 'Thank you for choosing XXXX Holidays for your 
dream vacation, we are pleased to confirm your trip- '+data[i][3]+' 
departing on  '+Utilities.formatDate(data[i] 
[4],Session.getScriptTimeZone(),"dd-MMM-yyyy")+'.'
        message1+='Please submit your visa documents by 
'+Utilities.formatDate(tempDate,Session.getScriptTimeZone(),"dd-MMM- 
yyyy")+' to avoid delays in visa processing.'
        message1+='If there are any further queries, please be in touch 
with your sales representative- '+data[i][6]+' or you may call '+data[i] 
[5]+' office for further assistance. Our offices are open from 1100 to 1900 
hrs from Monday to Saturday.'
        message1+= 'Thanks & Kind regards,'
        message1+= 'Team XXX'
        }

这是当前输出:

尊敬的 ABC XYZ 先生感谢您选择 XXXX Holidays 来度过您的梦想假期,我们很高兴确认您的旅行——南非探索之旅将于 2019 年 5 月 12 日启程。请在 2019 年 3 月 18 日之前提交您的签证文件,以避免签证处理延误。如果有任何进一步的疑问,请联系您的销售代表 - Thomas Bond,或者您可以致电孟买办事处寻求进一步帮助。我们的办公室从星期一到星期六的 1100 到 1900 小时开放。谢谢和问候 XXX

预期输出:

亲爱的 ABC XYZ 先生

感谢您选择 XXXX Holidays 为您的梦想假期,我们很高兴确认您的旅行 - 南非探索之旅将于 2019 年 5 月 12 日启程。

请在 2019 年 3 月 18 日之前提交您的签证文件,以避免签证处理延误。如果有任何进一步的疑问,请联系您的销售代表-Thomas Bond,或者您可以致电孟买办事处寻求进一步帮助。

我们的办公室从周一到周六的 1100 到 1900 小时开放。

感谢和问候

XXX

4

1 回答 1

0

\n需要进行 urlEncoded 以使 api 将其%0A呈现为新行。

 if(data[i][4]!="")
        {
            var tempDate=new Date(data[i][4])
        tempDate.setDate(tempDate.getDate() - 55);
        var message1 = 'Dear '+data[i][13]+' '+data[i][12]+' '+data[i][11]+' '
        message1+= '%0A%0AThank you for choosing XXXX Holidays for your dream vacation, we are pleased to confirm your trip- '+data[i][3]+' departing on  '+Utilities.formatDate(data[i][4],Session.getScriptTimeZone(),"dd-MMM-yyyy")+'.'
        message1+='%0A%0APlease submit your visa documents by '+Utilities.formatDate(tempDate,Session.getScriptTimeZone(),"dd-MMM-yyyy")+' to avoid delays in visa processing.'
        message1+='If there are any further queries, please be in touch with your sales representative- '+data[i][6]+' or you may call '+data[i][5]+' office for further assistance. %0A%0AOur offices are open from 1100 to 1900 hrs from Monday to Saturday.'
        message1+= '%0A%0AThanks %26 Kind regards,'
        message1+= '%0A%0ATeam XXX '
        }
于 2019-01-10T19:16:19.537 回答