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
rameshramesh 

i want to send email when i clicked on send email button created using aura component

hi i have one object called information   in this i had one field lookup with user  so  i created one button action using aura , now i clicked on that button i need to send email to person whos in the lookup field using aura 
SubratSubrat (Salesforce Developers) 
Hello Ramesh ,

To send an email to the user who is in the lookup field of the "Information" object, you can create an Aura component that uses the lightning:button and lightning:emailForm components to display an email form and send the email.

Here's an example code snippet for the component:
 
informationButton.cmp:

<aura:component>
    <aura:attribute name="recordId" type="String" />
    <aura:attribute name="userInfo" type="Object" />
    <lightning:button label="Send Email" onclick="{!c.sendEmail}" />
    <lightning:emailForm aura:id="emailForm" />
</aura:component>
In the controller, you can use the force:recordData component to retrieve the user's email address from the lookup field and pass it to the lightning:emailForm component.
informationButtonController.js:

({
    sendEmail: function(component, event, helper) {
        var recordId = component.get("v.recordId");
        var userInfo = component.get("v.userInfo");
        var emailForm = component.find("emailForm");

        $A.createComponent(
            "lightning:formattedEmail",
            {
                "value": userInfo.Email,
                "subject": "Regarding Information record",
                "body": "Hello, I'm contacting you regarding the Information record with ID " + recordId
            },
            function(formattedEmail) {
                emailForm.set("v.body", formattedEmail);
                emailForm.submit();
            }
        );
    }
})


This code uses the lightning:formattedEmail component to generate an email with the user's email address as the recipient, a subject, and a body message that includes the ID of the Information record. The email is then submitted using the submit() method of the lightning:emailForm component.

If this helps , please mark this as Best Answer.
Thank you.