• Tyson Kirksey
  • NEWBIE
  • 0 Points
  • Member since 2020

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
How would one go about adding opportunities to a priority list queue? We have a situation where we are unable to sell to all interested buyers, so we are managing sales with priority lists (or queues, first in - first out).  Ideally, we would want to be able to quickly and easily add an opportunity to a "sales queue" and the system would keep them sorted as opportunities come in and out. 
in an apex future method launched by a trigger I am using SingleEmailMessage to send email messages to specific email addresses, using a Lightning EmailTemplate, following almost the same approach mentioned here: Trigger to send email with related attachments
All works great if the EmailTemplate has no attachment. Instead, if the same EmailTemplate has an attachment, then the SendEmail() command generates the following error:
SendEmail failed. First exception on row 0; first error:INVALID_CROSS_REFERENCE_KEY, invalid cross reference id: []
It seems that SingleEmailMessage does not support EmailTemplates with attachments. Anyone had the same experience?
Please note that my org is with Summer '18 and that email settings related to EMAIL ATTACHMENTS are "Include as attachment up to 3 MB or as links if more". I noticed that if settings are "Always as links" then the error does not happen (but links added to the sent email will not work).
The same template sent manually via Lightning Email Composer will work, either with "Include as Attachment" or "Always as links settings."
My current conclusions are: * the Lighting composer does not just use the SingleEmailMessage.sendEmail command: it will do a lot of pre processing before, in order to manage attachments properly. This means for example create a proper public link for the attachment. * in order to send emails via apex, we'll need to re-implement the same logic.
Anyone has any idea about this / did it already?
Best
Sebastiano
  • June 21, 2018
  • Like
  • 0