0

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>{'patrick@avectek.com'});

 lstMsgs.add(msg);

 // Send the emails in a transaction, then roll it back
 //Savepoint sp = Database.setSavepoint();
 Messaging.sendEmail(lstMsgs);

I appreciate any thoughts!

2
  • Since FinancialForce is a 3rd party app, have you checked with their support? Aug 3 at 15:48
  • Hi David, I have but no answer yet... I figured that someone out there may have done the same thing. Worth a try!
    – Patrick W
    Aug 4 at 12:47
0

Just want to tie up loose ends... the issue was that FF has all sorts of stuff going on when an Invoice is posted. What I ended up doing was to add a delay before sending the email, and that helped the issue I was having.

Not the answer you're looking for? Browse other questions tagged or ask your own question.