Question

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 = "random@random.random"
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.

Was it helpful?

Solution

You are missing some quotes somewhere. Make sure your quoting looks similar to this:

window.location.href = "mailto:" + email + "?subject=" + subject;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top