Garbled text in mail subject using mailto: under ASP.NET
This is my first question on StackOverflow so if I'm doing something wrong when asking this question I welcome any pointers as to how I should've posed it instead, or any further information needed.
I have developed a small ASP.NET/C# site which generates mailto-links with a preset subject/body. However for some reason my mailto:-lin开发者_运维百科ks end up garbling non-standard letters (e.g. ååö) when opened in Outlook 2003. In Outlook 2010 it seems to work.
Sample code (apologize the Swedish):
<a href='mailto:" + emails + "?subject=Inflödning till " + language +
" för jobb nr " + projectID + " är klar. Tidsåtgång: " + time + "'>
Skicka mail till PL?</a>
(note that this happens on static links without C# variables as well)
Garbled text sample from Outlook 2003 mail window:
Inflödning till en för jobb nr 111111 är klar. Tidsåtgång: 1
I have specified UTF-8 encoding in the Web.config but I'm assuming this isn't the problem. I probably have to specify the encoding in the subject itself, but I am not sure about how to do that.
Edit: It would seem Outlook 2003 has a tough time handling UTF-8 mailto support. See for example this question. Outlook 2010 has an explicit "UTF-8 support for mailto protocol" switch under options. 2003 is missing this. Any ideas on how to get around this? UrlEncoding() doesn't seem to help.
Make sure you have the character encoding set
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
Should appear at the top of your page - with charset=
set to whatever character set Swedish use (Google has lead me to believe ISO-8859-1)
Take a look here which seems to use a javascript function to correctly escape the characters. I believe HttpUtility.UrlEncode(String) within the code behind will also have the same effect.
Does outlook perhaps have a different encoding specified?
EDIT:
Found this here
In versions of Outlook prior to the 2007 version, Outlook would assume the system codepage had been used to encode the URI. This means that this scenario would only work with older versions of Outlook, if the document you’re viewing has the same character encoding as your current system codepage.
This would seem to point to the problem that the system code page is NOT using Swedish (ISO-8859-1) so the remedy to the situation appears to be:
- Upgrade Outlook
- Change System Encoding to ISO-8859-1 (the client thats running Outlook)
精彩评论