I need to know if its possible to pass variables to the mailto: method.
I want to have something along the lines like this, so it opens a new email on outlook.
var email = "[email protected]"
var subject = "test"
window.href = "mailto:email?subject=subject"
Now i want to know if i can pass these variables. I don't care about the body of the email I just wanna have the email address and the subject line passed in. I can't ActiveXObject because my code is on the server side rather then the client side so it wont have permission to create objects. Or at least thats what i got from reading into opening outlook from javascripts.
I need to know if its possible to pass variables to the mailto: method.
I want to have something along the lines like this, so it opens a new email on outlook.
var email = "[email protected]"
var subject = "test"
window.href = "mailto:email?subject=subject"
Now i want to know if i can pass these variables. I don't care about the body of the email I just wanna have the email address and the subject line passed in. I can't ActiveXObject because my code is on the server side rather then the client side so it wont have permission to create objects. Or at least thats what i got from reading into opening outlook from javascripts.
Share Improve this question asked Sep 15, 2013 at 1:34 ZeRaTuL_jFZeRaTuL_jF 5922 gold badges4 silver badges20 bronze badges 7-
1
You replied to your own question. Just use
window.location.href = "mailto:" + email + "?subject=" + subject;
? – opatut Commented Sep 15, 2013 at 1:37 - @opatut the problem is that i have tried the expression that you have, and all it does is print the actual +email+ into the email rather than what the variable contains. Do i need something special or am i missing something. – ZeRaTuL_jF Commented Sep 15, 2013 at 1:58
- You are probably mixing or missing quotation marks. They are important! – opatut Commented Sep 15, 2013 at 2:02
- @ZeRaTuL_jF: this works fine - jsfiddle/CUEEr – Qantas 94 Heavy Commented Sep 15, 2013 at 2:03
- I guess I'm just missing typing something. I shall let you guys know when I get back to working on this. Thank you – ZeRaTuL_jF Commented Sep 15, 2013 at 2:22
1 Answer
Reset to default 2You are missing some quotes somewhere. Make sure your quoting looks similar to this:
window.location.href = "mailto:" + email + "?subject=" + subject;