About

all about SFDC

Sunday 25 March 2018

Lightning Component for Sending Email for List View Selected Records and using Email Templates

11:12

Hi there, At the time of this blog post, There is no standard Lightning component available for Email composer, So I created a custom component for sending Email and mimic of the standard email composer and also for sending Listview selected records.

I assumed sending email for person accounts (person accounts by default not available in salesforce you have to rise a case to enable them) of Opportunities. Please choose different object for sending(from contact List view)  since if you don't have person accounts enabled you will get compile errors.

You also need to create a rich text field in any object since we don't have standard richtext tags in lighting at the time of posting this blog post. We need rich text field to mimic the email composer screen and also to render the text review of template selected.

I have used a List view button of type visualforce in opportunities List view and in visualforce page i have placed Lightning Component.

The list view selected records will be sent to Lightning Component.

Get the snippets below to image.





Visualforce Page:


Controller Extension:
EmailComp:
Controller.js:
Helper.js:
EmailComp Apex Class:



I did not mentioned the snippet for the component "c:reUsableMultiSelectLookup" here. Because it is a custom look up component that can be available from many places like salesforce forums and blogs. All you need to do is to tweak the init section of your look up component by passing the selected items to display them automatically. 

8 Comments

  1. Great work! I see that you used Reusable Multi Select Lookup. To avoid displaying ticked records in the same row as search bar I would suggest adding slds-show class to lookup-pill in ReusableMultiSelectLookupCtrl. Thanks for this example.

    ReplyDelete
  2. Great Idea.I have developed same thing in org.but i am getting error,This page has an error. You might just need to refresh it.
    Aura.loadComponent(): Failed to initialize application.
    An internal server error has occurred
    Error ID: 1863109829-477750 (412317498)

    ReplyDelete
    Replies
    1. im getting the same error.
      did you find any solution please?

      Delete
  3. it's same too me :
    An internal server error has occured
    Error ID: 2017495085-40293(1121393504)

    ReplyDelete
    Replies
    1. im getting this error too.
      Have you been able to debug it?

      Delete
  4. Messaging.SendEmail(singlemessagelist) method will insert EmailMessage and if you have trigger on EmailMessage than the trigger will be called multiple time in single transaction. Ex. if you have 10 emails to send than the trigger will be called 10 times. This is the special case Messaging.SendEmail() internally insert the EmailMessage. Make sure if you are going to use this for MassEmail it may fail because of SOQL limit exception.

    ReplyDelete
  5. I really need this one that works to pass data from email template templates to textarea in LWC.

    ReplyDelete
  6. im getting this error

    An internal server error has occurred
    Error ID: 337574872-157034 (-897633097)

    any help on how to debug this please?

    ReplyDelete

Note: only a member of this blog may post a comment.

Powered by Blogger.

Contact form

Name

Email *

Message *

Visualforce

Apex

Lightening UI

Translate

Comments