I am following link: https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_email_sending_attachments.htm where I want to send the case attachments in email along with the standard format for the following scenario.

  1. Once Case approved, email should be sent to Risk & Legal team with case attachment
  2. Once Case rejected, email should be sent to Risk & Legal team with case attachment

How we can do that ?

I have an html email template which has header and footer. but not sure how to send attachments in that ?

  • How far you have achieved? Did you try at your own? – Santanu Boral Apr 27 '17 at 17:43
  • I developed Approval Proccesses and its sending emails properly, now I am not sure how to send case attachments – user4567570 Apr 27 '17 at 17:44

You can take this approach.

  1. Create a picklist field like Approval Indicator which will store if case is Approved or Rejected.
  2. Update this field via workflow field update from Approval process action.

Note: In the Workflow field update configuration, select the checkbox "Re-evaluate Workflow rules after Field Change"

  1. Create a Process Builder's process based on this criteria where you will call @invocableMethod (passing CaseId as parameter)

  2. In the Invocable method,

    • retrieve the case Id
    • prepare SOQL query to retrieve all the attachments
    • Create an instance of Messaging.SingleEmailMessage().
    • Create each instances of Messaging.EmailFileAttachment() for each attachments.
    • Finally send the email.

Refer InvocableMethod

and Creating an Email Attachment

  • Thank you for this, since I am beginner in salesforce, so wont be able to it unless I see some code and actual steps. Do you've another way ? – user4567570 Apr 27 '17 at 19:15
  • I have put the reference in the answer – Santanu Boral Apr 27 '17 at 19:21
  • I have given proper approach, you should first at your own to do that. If you face any issues then post with that in separate question. If you are satisfied with this answer then choose this, so that others may find this useful – Santanu Boral Apr 27 '17 at 19:24

I don't think you can do it with pure email template, you'll need some Apex.

I think the closest it can get is to create the links to attachments (SF converts attachments > 3 MB to links anyway).

    <messaging:emailTemplate subject="hello" recipientType="Contact" relatedToType="Case">
    <messaging:htmlEmailBody >
        <p>This will list link to attachments</p>

        <apex:repeat value="{!relatedTo.Attachments}" var="a">
        <p><a href="{!LEFT($Api.Partner_Server_URL_280, FIND(".com/",$Api.Partner_Server_URL_280)+3)}/{!relatedTo.Id}">
</a>({!a.BodyLength} B)</p>
    <messaging:plainTextEmailBody >
        <apex:repeat value="{!relatedTo.Attachments}" var="a">
            {!a.Name} {!a.ContentType} {!a.Body} <!-- this "Body" reference causes the compilation to fail -->

  • after <apex:repeat value="{!relatedTo.Attachments}" var="a"> you can use {!a.Id} to find attachment Id – Avijit Das May 2 '17 at 9:46
  • Will it get attached while sending email to Risk Team ? – user4567570 May 2 '17 at 9:48
  • yes they should get. – Avijit Das May 2 '17 at 10:27
  • Yes but how to send actual attachments ? How to call Apex code from VF Email Template ? – user4567570 May 2 '17 at 11:24
  • I think you tell me to download attachments by providing links. I dont want to download that, just wanted to send case attachment in email. I have already approval process in place !! – user4567570 May 2 '17 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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