0

I want to send email after showing preview. For preview, I am using slds-modal in lightning component. It's layout is as shown in image. Is it possible to save html code of modal content and send it over email? enter image description here

ComponentA.cmp

<div class="slds-m-around_xx-large">
        <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
            <div class="slds-modal__container">
                <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
                    <c:EmailPreview/>
                </div>
                <footer class="slds-modal__footer">
                    <lightning:button variant="brand" label="Send Email" title="Send Email"
                                      onclick="{! c.sendEmail }"/>
                    <lightning:button variant="neutral" label="Cancel" title="Cancel"
                                      onclick="{! c.closeModal }"/>

                </footer>
            </div>
        </section>
        <div class="slds-backdrop slds-backdrop_open"></div>
</div>

EmailPreview.cmp

<aura:component >
 <div>
    <table border = "2">
        <tr>
            <th class="slds-size_1-of-3">Header</th>
            <th class="slds-size_1-of-3">Header</th>
            <th class="slds-size_1-of-3">Header</th>
        </tr>
        <tr>
            <th>Header</th>
            <td>Data</td>
            <td>Data</td>
        </tr>
        <tr>
            <th>Header</th>
            <td>Data</td>
            <td>Data</td>
        </tr>
     </table>      
</div> 

  • You should start by reading how to call an Apex method from a Lightning component: developer.salesforce.com/docs/atlas.en-us.lightning.meta/…. Then, you can indeed send an email from Apex. – Martin Lezer May 31 at 14:51
  • agree with @MartinLezer, you can send email by calling Aura Enabled Apex Method, – sdandamud1 May 31 at 14:52
  • Yeah, but I need email layout to be same as preview layout. I have a java listener which sends email. I just need to save HTML code of this preview. – Pooja May 31 at 15:17
0

I haven't tried this, but you should be able to use HTML JS DOM methods like document.getElementById().innerHTML in your Javascript controller and/or helper to get the HTML string, which you can then pass to your Apex controller to send outbound email.

See this Apex Developer Guide section for info about the Messaging class and setHtmlBody() method.

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.