Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

mailto syntax 2

Status
Not open for further replies.

elmiocid

Technical User
Jul 29, 2007
22
0
0
ES
Hello

I have a mailto code to include some data in the body of the email message. But when it renders, it doesn't render the special characters, like accents etc.

I have put the meta tag

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

in the head of all the pages, which renders the writing inside the pages ok, but not in the body of the messages created by the mailto command

How do I make the conversion then

Thanks in advance

elmiocid
 
Could you also please post the code you are using in the body of the HTML for your mailto?
 

Thanks for yr answer. I tried the charset you said but it didn´t work, it still converts the special chars into funny symbols... Here is the coding I put in the body of my page. As you can see it´s the Spanish chars for the ñ, and the accents that go in some words. It´s odd that they appear ok in the body of all the pages in the website, but not in the body of the email message that mailto produces automatically....


<a href="mailto:info@mywebsite.com?body=Más información etc etc
%0a3 cuantos baños, Salón %0a %0a Your message aquí:"><img src="images/email.png" width="227" height="16"></a>

Thanks again MikeyJudd

elmiocid
 
Could character encoding be a problem between any one of (or a combination of) the server, the browser, and the email client? There are too many variables here. I'd stick to using a form instead of mailto.
 

Hi

Darryn, I don�t quite understand when you say getting rid of punctuation, in the body of the message I want some Spanish text which needs that punctuation

When I run the webpage in old IE6, it does work, funny enough, but not the latest Google Chrome or Firefox... as Spamjim says it could be a problem from different angles.. but I cannot use forms, I need to use the email link...

Any suggestions....

Thanks for your comments anyway

elmiocid
 
You are likely going to have to encode the accents and other special punctuation like you encoded your line breaks (%0a3). In fact you should be encoding the entirety of your body message, as some of those characters are not valid characters in a URL such as the one used with the mailto command.

You can use the w3 table to manually encode each accent and special character you need, or simply use a javascript function to accomplish this:

Code:
script type="text/javascript">
          
	function encodeBody()
	    {
		  var mailToBody = "Más información etc etc %0a3 cuantos baños, Salón %0a %0a Your message aquí:";
		  var Href=encodeURI(mailToBody);
		  document.getElementById("mylink").href="mailto:info@mywebsite.com?body=" + Href;
		}
</script>

Put the Js code between the <head> tags of your webpage, and add the onclick event to your link in your HTML.

HTML:
<a href="" onClick="encodeBody();" id="mylink">Click Me</a>

As an addendum, if the user does not have an email client installed, and properly configured your emailing will still fail. Newer OS'es offer the opportunity to send the mailto link to a web mail client though.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Web & Tech
 

Thank you very much, mate, it worked. I encoded all the special characters and it works smooth like silk. The javaScrip code I don´t need it in this occasion, as every page needs a different body content in the mailto code, but I´m keeping it for further usage. Thanks again, phil, the vacunita did the trick! and thanks to all the others for trying, it feels good to belong to this family!

take care!

elmiocid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top