I've been trying to send the financial force email that from Apex that is called from a Process. As I understand the invoice should be attached when the email template is used with the WhatID set (hardcoded for now).
I have have been getting the following error:
Line: 25, Column: 1 System.EmailException: SendEmail failed. First exception on row 0; first error: STRING_TOO_LONG, Content Type: data value too large: application/pdf; name="=?ISO-8859-1?B?U29iZXlzIFVyYmFuIEZyZXNoIDcwMSA/IE1vdW50?= =?ISO-8859-1?B?IFBsZWFzYW50IEludm9pY2UgU0lONjAzMTM0LnBkZg==?=" (max length=120): [ContentType]
Code so far:
public static void sendMail(){
// Pick a dummy Contact
Contact c = [select id, Email from Contact where email <> null limit 1];
// Construct the list of emails we want to send
List<Messaging.SingleEmailMessage> lstMsgs = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage msg = new Messaging.SingleEmailMessage();
msg.setTemplateId( [select id from EmailTemplate where Name='Sales Invoice Standard' limit 1].id );
msg.setWhatId('a5Q4N000000VCuZUAW');
msg.setTargetObjectId(c.id);
msg.setToAddresses(new List<String>{'[email protected]'});
lstMsgs.add(msg);
// Send the emails in a transaction, then roll it back
//Savepoint sp = Database.setSavepoint();
Messaging.sendEmail(lstMsgs);
I appreciate any thoughts!