更新时间:2022-11-03 08:05:10
在我的环境中,我确认从电子邮件中检索附件*.csv
文件时,mimeType的检索方式为application/vnd.ms-excel
.我认为什么都没有发生"的原因是这样.那么这些修改呢?我认为针对您的情况有几种解决方法.因此,请考虑将这些修改视为其中的3种.
In my environment, I confirmed that when the attached *.csv
file is retrieved from the email, the mimeType is retrieved as application/vnd.ms-excel
. I think that the reason of "nothing happens" is this. So how about these modifications? I think that there are several workarounds for your situation. So please think of these modification as 3 of them.
application/vnd.ms-excel
请在if (attachment.getContentType() === "text/csv") {
之前添加以下脚本.
Please add the following script before if (attachment.getContentType() === "text/csv") {
.
attachment.setContentTypeFromExtension();
请进行如下修改.
Please modify as follows.
if (attachment.getContentType() === "text/csv") {
到:
if (attachment.getContentType() === "application/vnd.ms-excel") {
请进行如下修改.
Please modify as follows.
if (attachment.getContentType() === "text/csv") {
到:
var fileName = attachment.getName().toUpperCase().split(".");
if (fileName.length > 1 && fileName[1] == "CSV") {
setContentTypeFromExtension()
从文件名的扩展名中设置mimeType.application/vnd.ms-excel
.
setContentTypeFromExtension()
.application/vnd.ms-excel
.如果这些不是您想要的,对不起.
If these were not what you want, I'm sorry.