Invoke / click a mailto link with JQuery / JavaScript

前端 未结 4 583
遇见更好的自我
遇见更好的自我 2020-12-13 03:18

I\'d like to invoke a mailto link from JavaScript - that is I\'d like a method that allows me to open the email client on the users PC, exactly as if they had clicked on a n

4条回答
  •  一个人的身影
    2020-12-13 03:48

    the working answer for me, tested in chrome, IE and firefox together with outlook was this

    window.location.href = 'mailto:address@dmail.com?subject=Hello there&body=This is the body';
    

    %0d%0a is the new line symbol of the email body in a mailto link

    %20 is the space symbol that should be used, but it worked for me as well with normal space

提交回复
热议问题