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
Hari N 20Hari N 20 

Sending Attachment from Notes & Attachment to Email

Hi All,
I have created a Email service to create a record in a custom object with a attachment from any email.
I have two field in this object, one email field and one rejected checkbox.
In email field, sender of email address will populate.
Now, when ever I selects rejected checkbox, I want to send a auto - email back to the sender with the same attachment which is in the same notes & attachmentment section of that record.

Please suggest best approach to solve this

Thanks in Advance

Arpit Jain7Arpit Jain7
Hari, I think you can use seingle email message mehthod using apex and include attchments from your respective records.

Below is a sample code which you can use for your reference:

Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setSubject('Give the subject......');
mail.setPlainTextBody('Give the email body');
List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
for (Attachment a : [select Name, Body, BodyLength from Attachment where ParentId = :case.Id])
   // Add to attachment file list Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
emailMessaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });

Hope this helps !!

Sagar Wahal 1Sagar Wahal 1
Hi Hari,

You will have to send the email from the object's trigger.

In the before update context of your trigger you can check if the 'rejected' checkbox has been updated to 'true' or not. If it has, invoke your utility to send the email to the customer.

Refer below link for sample code on how to do this:

Below link will help you in attching your file to your email: (

Let me know if you face any issues.

Sagar Wahal
Hari N 20Hari N 20
Hi Sagar & Arpit,
Thank you for your answer.
But, bothsolutions are not working.

This is my sample record.
Object name : ABCD__c
Email : ABCD@GHJ.COM (Field data type is Email)
Rejected (Checkbox)
Notes & Attachments
If I selects Rejected check box, A.doc should go to ABCD@GHJ.COM.
jaya sai prasadjaya sai prasad
If you want to send an Email with Attachment a native salesforce app MassMailer DOCS is perfect for you.
MassMailer DOCS let’s you send mass email attachments to your leads or contacts while securely storing your files with Rackspace Cloud Files.
You can try this app by installing from appexchange  -Massmailer Docs
You can learn more details about the product on this website -