开发者

Javascript to open default email client doesn't work

I need to perform following tasks;

  1. on click of link (could be link button, <a> or Hyperlink) the default email program at client machine should open up.

  2. Javascript for the same has been written as below:

string adminemail= "xyz@abc.com"; //fetches admin email address; display in To Field

ScriptManager.RegisterStartupScript(this.updatePanel1, typeof (string), "defaultemail", "window.open('mailto:" + adminemail+ " ');", true);

开发者_如何学运维

But, using the link button is not correct option, as it triggers postback. Hence i thought of using the <a> tag, but i am not sure how to link that with the javascript.

How to execute the JS with the help of <a> tag? OR Suggest some possible solution for the same.

Please guide!

Thanks!!


Why not just use mailto? For example <a href="mailto:xyz@abc.com">Send email to the admin</a>

You can also include cc,bcc,subject and body fields in the query string to customize the email. See the IANR syntax reference.


An anchor or link button with href/src set to mailto: protocol will do fine, e.g:

<a href="mailto:[email address]">Mail me</a> 
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜