How do you send email from table view using mailto:, grabbing emailaddress and body from values?

How do you send email from table view using mailto:, grabbing emailaddress and body from values?

rmeetinrmeetin Posts: 100Questions: 24Answers: 1

The common method of using mailto in a form to send email is:

<a href="mailto:john.doe@wysiwyg.com?subject=Good morning Mr Phelps" >Send msg</a>

I have fields/values for name, email, msg_body and I wish to set it up to click on a field link and have it open up mailto prepopulated with email address, body, and subject. Here is what I have for the column:

      { data: null, render: function ( data, type, row ) {
        // return '<a target="_data.id" href="'+data.url+'" >'+data.url+'</a>';
        // return '<a href="mailto:$email?subject=$subject&body=$body>Send</a>';
        return '<a href="mailto:'+data.email+'?subject=Good morning Mr Phelps?body='+data.body+'" >Send msg</a>';
        }
      },

Clicking on the Send msg link opens a compose window (Thunderbird) fine but the To line has:

To: data.email <>

And the body is failing. Something about: '+data.email+'

Answers

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    This here is showing the email address correctly - though it is just an extension number so not entirely identical. The HTML is being correctly formed according to SO, so it might be worth posting there is no joy as it doesn't look like a DataTables issue.

    Colin

  • rmeetinrmeetin Posts: 100Questions: 24Answers: 1

    It seems I don't understand. I clicked on the here example then on one of the Send msg links. The To line has a number (id? and <>

    1562<>

    the body should be within the body not appended to the subject. Here is what I see:

  • colincolin Posts: 15,240Questions: 1Answers: 2,599

    I tried it with Gmail/Chrome, and it looks like this:

    so there appears to be a difference in how it's rendered. As I mentioned, it would be worth asking on StackOverflow, as the problem appears to be more with the mailto URL than DataTables. DataTables is displaying it correctly, it just seems the mail clients are behaving differently.

    Colin

  • rmeetinrmeetin Posts: 100Questions: 24Answers: 1

    My email client is Thunderbird.

  • allanallan Posts: 63,441Questions: 1Answers: 10,459 Site admin

    Can you give me a link to your page so I can take a look and help to debug it please?

    Allan

This discussion has been closed.