PDA

View Full Version : Adding a JSP variable to a Mailto Tag


kathryn
10-18-2002, 09:58 AM
Hi,
I am trying to add a JSP variable to the body string to be put in an <a href="mailto: ">tag as follows

<a href="mailto:me@something.com?Subject=i%20thought%20you%20might%20like%20to%20read%20this&Body=<a href="<%=EmailURL%>">click here</a>

Where <%=EmailURL%>should be the destination of the link which appears in the body of the mail.

However the link appears in the email but just links to http://<%=EmailURL%>.

Please help!!!!

Thanks, Kathryn

whammy
10-19-2002, 01:03 PM
The problem is you have an <a href> inside another <a href> which is incorrect HTML. Try:


<a href="mailto:me@something.com?Subject=I%20thought%20you%20might%20like%20to%20read%20this&Body=<%=EmailURL%>">click here</a>


:D

P.S. And get rid of the space the forum puts in between the ? and Subject!

Although if you're using JSP you might want to look at its server-side email capabilities as an alternative to using "mailto". ;)

Mr J
10-19-2002, 04:01 PM
Use document.write.
The variable "where" could be placed in a script in the HEAD section








<script>
where="Kathryn@home.co.uk"

document.write("<a href='mailto:me@something.com?Subject=i%20thought%20you%20might%20like%20to%20read%20this&Body=E-mail me at "+where+"'>click here</a>")
</script>