I'm sending a attachment by email as a PDF. Not sure how and when it's happening, but sometimes it seems to change the extension of my pdf to pdf.html. It used to work perfectly before without to specify the contentType, just by mentioning .pdf in the fileName. I tried to add the contentType, but doesn't change anything. Here is a piece of the code I'm using:
Attachment att = [select id, body from Attachment where ParentId = :parentId];
Messaging.EmailFileAttachment emailFileAttachment = new Messaging.EmailFileAttachment();
emailFileAttachment.setFileName('InvoiceXXXXXX.pdf');
emailFileAttachment.setContentType('application/pdf');
emailFileAttachment.setBody(att.Body);
emailFileAttachments.add(emailFileAttachment);
...
singleEmailMessage.setFileAttachments(emailFileAttachments);
...
emails.add(singleEmailMessage);
....
Messaging.sendEmail(emails);
Anyone has ever got the same problem before?