Create Email Button and send mail to selected row onclick

Create Email Button and send mail to selected row onclick

N-tronelN-tronel Posts: 7Questions: 4Answers: 0

Hi everybody,

Sorry for my bad english.

I would like to add a functionality to my table with editor.

**Is there any possibility to add a custom email button that sends email to the selected row onclick ?
**
I guess I can use phpmailer, but I don't know how to get the email selected on the table and then send it to my phpmailer template.

Can somebody give me some tricks to achieve that ?

Thank you for the help !

Answers

  • colincolin Posts: 15,161Questions: 1Answers: 2,587

    You would create a Button that would send the necessary information to your script via an ajax command. That's not an Editor specific feature.

    This example shows how to create a custom button. You would send back details of the selected rows, using the Select extension.

    Hope that helps,

    Colin

  • N-tronelN-tronel Posts: 7Questions: 4Answers: 0
    edited September 2020

    Thank you,

    I found a solution with smtp.js . Here is my code if someone need it :

    '''{
    text: 'Send an Email',
    action: function ( e, dt, node, config ) {
    var rows = dt.rows( {selected: true} ).indexes();
    var data = dt.cells( rows, 17 ).data();
    var template = "

    Test template

    "
    Email.send({
    SecureToken : "//",
    To : data.join(''),
    From : "{{from}}",
    Subject : "{{subject}}",
    Body : template,
    }).then(
    message => alert('Email sent to ' + data.join('') )
    );
    }}, '''

    Thank you for you help.

This discussion has been closed.