?
Solved

Special Characters NOT displaying properly in javascript MAILTO

Posted on 2009-02-11
3
Medium Priority
?
2,527 Views
Last Modified: 2013-11-19
I have a Javascript mailto function embedded in my web page, whose encoding is set to UTF-8. So the special characters such as characters showing French accent and Chinese characters show up fine on the web page.

However, when I try to use the maito function, the subject and body having these French and Chinese characters get distorted in Outlook

Please see code below. How do I fix this?
mailto function:
 
function sendEmaill() {
	    window.location.href="mailto:?subject=Votre ami vous a invité à consulter un lien sur le site Web Google&body=On vous a invité à consulter un lien du site Web Google, www.google.com. Cliquez sur le lien ci-dessous pour afficher la page :%0A%0D" + escape(window.document.location);
	}
 
 
calling code:
 
Send to friend: <a href="javascript:sendEmail()">Send a friend</a>

Open in new window

mailto-screenshot.doc
0
Comment
Question by:vgnuser
2 Comments
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 1000 total points
ID: 23632461
Here

var subject = 'Votre ami vous a invité à consulter un lien sur le site Web Google';
var body= 'On vous a invité à consulter un lien du site Web Google, www.google.com. Cliquez sur le lien ci-dessous pour afficher la page :\n\n'+window.location.href;
function sendEmaill() {
window.location.href="mailto:?subject="+encodeURIComponent(subject)+"&body="+encodeURIComponent(body)
}

Open in new window

0
 
LVL 1

Assisted Solution

by:buri8128
buri8128 earned 1000 total points
ID: 24801884
I have tryed to use System.Web.HttpUtility.UrlEncodeUnicode and other methods of HttpUtility on the serverside  with aspnet.
But it did not work when I clicked the link and the mail client starts.
I used the brutal version proposed here with simple replace.
http://codebetter.com/blogs/peter.van.ooijen/archive/2004/05/24/mailto-links.aspx
He describes the same problem in the comments that I found.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Australian government abolished Visa 457 earlier this April and this article describes how this decision might affect Australian IT scene and IT experts.
Shows how to create a shortcut to site-search Experts Exchange using Google in the Chrome browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch the Search Engine Menu: In chrome, via you…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.
Suggested Courses
Course of the Month17 days, 5 hours left to enroll

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question