【发布时间】:2022-01-03 05:19:27
【问题描述】:
使用 Google Apps Script Gmail 库时,当我使用函数 GmailMessage.getPlainBody() 时,API 似乎将过去的一个段落拆分为多个,可能会使用字符限制。例如,我的电子邮件中有一段内容如下:
From the link you sent me, I gleaned that Gmail refers to their secure email as confidential.
但是当我在邮件上调用这个函数时,它变成了:
From the link you sent me, I gleaned that Gmail refers to their
secure email as confidential.
而且,当我在新的行分隔符上拆分电子邮件文本并进行一些清理以使用我的输出创建一个数组时,我最终得到:
['From the link you sent me, I gleaned that Gmail refers to their', 'secure email as confidential.']
我查看了this Reddit post,似乎处理了类似的问题。但是,我尝试了提出问题的人建议的解决方案:
body = message.getPlainBody().replace(/\r\n\r\n/gm,'aaaLINEBREAKERaaa').replace(/\r\n/gm,' ').replace(/aaaLINEBREAKERaaa/gm, '\r\r').replace(/ /gm,' ')
它并没有完全满足我的需求。有没有其他人遇到过这个问题,如果有,您有建议的解决方法吗?谢谢!
【问题讨论】:
-
虽然我不确定你的实际情况,但我提出了一个我曾经使用过的解决方法。你能确认一下吗?如果这对您的情况没有帮助,我深表歉意。
-
看起来很棒!如果其他人有想法,仍然会感激另一种选择,但这暂时可行!
标签: google-apps-script gmail gmail-api