1

I have to open a email window in which I need to provide one hyperlink and one onClick event in boday.

Here is my code.

ClickEmail : function (){
    var Subject = "Test";
    var body = "";
    body = body + "   Name1  " + record.name[0] + "%0D%0A";
    MyRecord  == window.location.href = 'mailto:?subject=Subject :'+Subject+'&body=My Body'+body 
}

Can anybody please explain me what I need to do for that.

shanky singh
  • 1,121
  • 2
  • 12
  • 24
  • Please check this link. http://stackoverflow.com/questions/247245/is-it-possible-to-add-an-html-link-in-the-body-of-a-mailto-link – Jhay Feb 22 '17 at 08:07

2 Answers2

5

You need to modify your body to include the hyperlink. Example: var body = "<a href='somelink'>Link title</a>";

You cannot add functions (your onClick event) to emails.

Deividas
  • 6,437
  • 2
  • 26
  • 27
  • This link is not clickable. What I need to mention there. Thanks for answer It works but not clickable – shanky singh Feb 22 '17 at 07:52
  • @shankysingh then the problem maybe that you are sending a plain text email and not an HTML email. In that case you need to update your question. – Deividas Feb 22 '17 at 07:54
  • I am sending exactly what I written in code. Wait let me figure it out the solution for that. Then I will accept your answer. Thanks for all – shanky singh Feb 22 '17 at 07:56
-1

You can try to create an <a> tag element with href="mailto:abc@exmaple.com", then call the click event on javascript on that <a> tag

For exmaple:

function mailTo(mailAddr){
    var aTag = document.createElement("a");
    aTag.href = "mailto:" + mailAddr;
    aTag.target = "_blank";
    aTag.id = "openMailClient";
    aTag.innerHTML = " ";
    aTag.click();
}

Try: https://jsfiddle.net/ogqwu1j2/

Solomon Tam
  • 739
  • 3
  • 11