You need to sign in to do that
Don't have an account?
Gurpreet Singh Sandhu
Trying to send attachments(all Formats) using Apex Email Service
Hello everyone,
USE CASE: When User finalize the Quote, sends an email along with Attachments(Quotes, POs, etc). I am using Visual Flow to get the Attachments and calling Apex Email Service.
WORKING: I am able to receive an email along with all the attachments, correct email template as expected. PDFs are coming along in the correct format.
ISSUE: All NON-PDFs attachments such as EXCEL, PNG, JPEGs are not showing in the correct format and infact, I am not able to open them from the Email.
Can someone please guide me to correct the issue? I beleive the issue is with:
q.setContentType('application/' + document.FileType);
Compelete Code for setting the Email Atatchment:
Guru Sandhu
USE CASE: When User finalize the Quote, sends an email along with Attachments(Quotes, POs, etc). I am using Visual Flow to get the Attachments and calling Apex Email Service.
WORKING: I am able to receive an email along with all the attachments, correct email template as expected. PDFs are coming along in the correct format.
ISSUE: All NON-PDFs attachments such as EXCEL, PNG, JPEGs are not showing in the correct format and infact, I am not able to open them from the Email.
Can someone please guide me to correct the issue? I beleive the issue is with:
q.setContentType('application/' + document.FileType);
Compelete Code for setting the Email Atatchment:
Messaging.EmailFileAttachment q = new Messaging.EmailFileAttachment(); q.setBody(document.VersionData); q.setFileName(document.Title); q.setContentType('application/' + document.FileType); attachments.add(q);Thanks in Advance,
Guru Sandhu
1. update line 3 to:
q.setFileName(document.Title + '.' + document.FileExtension); // make sure file FileExtension is included in your soql on ContentVersion.
2. Remove line 4.
q.setContentType('application/' + document.FileType);All Answers
1. update line 3 to:
q.setFileName(document.Title + '.' + document.FileExtension); // make sure file FileExtension is included in your soql on ContentVersion.
2. Remove line 4.
q.setContentType('application/' + document.FileType);It worked. much appreciated.