function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Kathryn BullockKathryn Bullock 

Send an Email with an attachment

Hi,

Is it possible to create a button that will send an email and add one of the attached files, but only the most recently added file?  Please let me know if this is possible.
PawanKumarPawanKumar
Please use code from here.
https://salesforce.stackexchange.com/questions/154340/select-attachments-from-notes-and-attachments-in-send-email

You just change the attachment query as below.
select Name, Body, BodyLength from Attachment where ParentId = :AccountId Order By LastModifiedDate DESC Limit 1

Please mark it best if it helps you. Thanks.
Kathryn BullockKathryn Bullock
Do I set the HTML body to reference fields from the record in the same way the email templates do?  Will this work in Lightning?  And how do I change the reciever of the email to a lookup contact field on the record?