我正在发送带有 3 个附件的电子邮件,它工作正常,但是当附件文件很大时,它会在我的电子邮件中添加带有文件名的额外扩展名,即 test.pdf 与 (test.pdf.html) 一起出现,并且邮件会转到垃圾邮件文件夹。下面是我的代码。
if(strAttachFile != null && strAttachFile != '' && fileBody != null) {
Messaging.Emailfileattachment efa1 = new Messaging.Emailfileattachment();
efa1.setFileName(objAttachment1.Name);
efa1.setbody(objAttachment1.Body);
fileAttachments.add(efa1);
}
if(strAttachFile1 != null && strAttachFile1 != '' && fileBody1 != null) {
Messaging.Emailfileattachment efa2 = new Messaging.Emailfileattachment();
efa2.setFileName(objAttachment2.Name);
efa2.setbody(objAttachment2.Body);
fileAttachments.add(efa2);
system.debug('---fileAttachments---'+fileAttachments);
}
if(strAttachFile2 != null && strAttachFile2 != '' && fileBody2 != null) {
Messaging.Emailfileattachment efa3 = new Messaging.Emailfileattachment();
efa3.setFileName(objAttachment3.Name);
efa3.setbody(objAttachment3.Body);
fileAttachments.add(efa3);
}
mail.setFileAttachments(fileAttachments);
system.debug('---mail---'+mail);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });