I'm trying to code an application which will allow users to send emails from outlook using the mailto tag. I know with the mailto, there involves limitation of # of characters that may be passed, as well as encoding.
Does anyone know the exact count of characters I can use, and what guidelines to follow when it comes to encoding special characters? What is counted in the max number of characters you can use? Body and Subject or the whole line including mailto syntax?
For example I will have the following:
<a href='mailto:test#gmail.com?subject=Test Mail&body=Line one.%0D%0ALine two.'>Test Link</a>
Would this be 69 characters??
Forgot to mention, supported browser will be IE6.
Any help would be appreciated.
Thanks
As far as I know there is no limit.
The HTML 4 spec says nothing about a limit
Authors may create links that do not lead to another document but
instead cause email to be sent to an email address. When the link is
activated, user agents should cause a mail program to open that
includes the destination email address in the "To:" field.
To cause email to be sent when a link is activated, specify a MAILTO
URL as the value of the href attribute.
http://www.w3.org/TR/WD-html40-970917/struct/links.html#h-13.2.2
However, many sites report a 256 character limit.
You should test to be sure.
You may also find this question and answers illuminating: What is the email subject length limit?
Same problem here, so far no good. IE9 has a limit of around 505 characters per href="...", Chrome 21 is better - around 2000 chars.
Update! According to this guys there is a workaround, and it seems to work for me:
ClientScript.RegisterStartupScript(this.GetType(), "mailto",
"<script type = 'text/javascript'>parent.location='" + longMailtoText +
"'</script>") ;
This will launch the script and open MailClient window as soon as client gets the response. LongMailToText should follow all standard rules, except for length - so far i was able to send over 2000 chars through it.
Related
I work with a legacy ASP.NET web application that has URLs that use query string values to pass information between pages. I ran into an issue with a couple of URLs that contain spaces, numbers, and dashes that I'm trying to understand.
Here's an example of the URL:
http://myserver.com/SelectReport.aspx?Name=My Report&ReportFile=my_financial_report&ReportTitle=My Financial Planning Across A 1-Year Or 2-Year Outlook
The problematic part of the URL is the ReportTitle query string value.
When I click the link in Internet Explorer 11 or Microsoft Edge, I get a Cant' reach this page. It took too long to connect to this website. Error Code: INET_E_CONNECTION_TIMEOUT error. It should be noted that the link works fine if I turn ON compatibility view settings in Internet Explorer 11.
When I click the link in Google Chrome, I get a `This site can't be reached. The connection was reset. ERR_CONNECTION_RESET" error.
If I delete the 2 in 2-Year, the link works. However, if I delete the 1 in 1-Year and leave 2-Year alone, the link does not work. I'd like to know why removing the 2 in 2-Year allows the link to work, but removing the 1 in 1-Year does not. This is true whether I replace spaces with %20 or not. Does anyone know the answer?
I know that I can replace the spaces in the ReportTitle query string value with plus signs (+) and it will work. This is likely the route I will take to fix the issue, but I was hoping to understand the issue better.
Thanks!
This is the continuation of my comments in the original post. I am writing this answer to share the demo example. It may not be a full answer.
There is absolutely no difference when you have spaces, or spaces are replaced by %20 or spaces are replaced by +. Also, I mentioned earlier your URL has valid characters including -.
See the three links below. I suspect it is your application that is dealing with URL encoding, decoding and having issues. It is not a general problem.
With Spaces
<br>
With %20
<br>
With +
I am trying to use the mailto function using an HTML form to populate a new message with some predefined text from an ASP string variable. I am using the syntax
<form action="MAILTO:someone#example.com?subject=<%= eSubject%>&body=<%= eBody%>" method="POST" enctype="text/plain">
where eSubject and eBody are string variables that have been drawn from values read from a DB and edited so that they use %20 instead of spaces and %0D%0A to represent new lines. The form contains no inputs and uses JavaScript to simply submit it straight away.
I have researched possible problems with the length of the string I am trying to pass to the body text (e.g. Limit on mail body when posting a mailto: form), but I get the impression it is up to a browser and only becomes an issue at fairly high character counts (depending on my inputs this varies between ~380 and 400 for my eBody string but is never more than 400).
The thing that is most frustrating is that my subject string (one line) populates the subject line of the new email as required. Could it be something to do with attempting to use newlines within my string? An example of the subject line is:
Query%20-%20Birmingham%20-%2025/03/2015%20at%2013:30
to produce subject line
Query - Birmingham - 25/03/2015 at 13:30
I am well aware that the general response to questions about using mailto is "Why are you doing that?!", but for in this case it is appropriate as the idea is to create an email that will always contain eBody (some info that is sent to customer services to show exactly what was happening at the moment of sending the query) and a message from the person sending the email, which will be different every time.
Any constructive help would be hugely appreciated. Thanks
It seems like the maximum character count can vary from browser to browser and also email client to email client (Getting around mailto / href / url character limit).
The accepted answer on this question (Effective maximum mailto: body lengths) mentions that Outlook Express's limit is 456 characters (possibly for the mailto link as a whole). So depending on your browser and possibly client, you may run into a limit. The other answer on that question could allow you to run some tests as well.
The w3c standard for mailto:, states:
According to RFC 822, the characters "?", "&", and even "%" may occur
in addr-specs. The fact that they are reserved characters in this URL
scheme is not a problem: those characters may appear in mailto URLs,
they just may not appear in unencoded form. The standard URL encoding
mechanisms ("%" followed by a two-digit hex number) must be used in
certain cases.
...
As described above, the "&" (ampersand) character is reserved in HTML
and must be replacded with "&". Thus, a complex URL that has
internal ampersands might look like:
Click
<a href="mailto:?to=joe#xyz.com&cc=bob#xyz.com&body=hello">
mailto:?to=joe#xyz.com&cc=bob#xyz.com&body=hello</a> to
send a greeting message to <i>Joe and Bob</i>.
Therefore your example;
<form action="MAILTO:someone#example.com?subject=<%= eSubject%>&body=<%= eBody%>" method="POST" enctype="text/plain">
Should probably have the &body encoded such that it becomes &body
<form action="MAILTO:someone#example.com?subject=<%= eSubject%>&body=<%= eBody%>" method="POST" enctype="text/plain">
I have UTF-8 page in which I have mailto links with template of body. But these template with data includes East Europian (Czech) characters. These characters messes up some email clients like Outlook 2007 and they are displayed like question marks or some other strange characters.
I know about "Enable UTF-8 support for mailto: protocol." setting in Outlook 2007, but from what I know about it's off by default.
Which charset-encoding should I use in mailto body for maximum compatibilty?
it clearly depends on client settings. in the company i work for we had a similar question. we ended up using ae for ä and so on.
we faced the problem that some clients running ms outlook 2003 were reading it as utf-8 while other clients running outlook 2003 were reading it as a defined ansi table.
another issue is involved in the usage of other mail clients. we also have a bring your own device program where employees could install linux or have mac books. they are using mozilla thunderbird, mutt and so on. other clients have set gmail as their prefered mailto: handler etc. so a global change of the outlook settings through a registry edit as in Rfilip's answer would not apply to us.
anyways.. you can only define the text body of the mail. sadly its impossible to define a html body through a mailto: link. if this would work, encoding could be defined through the body.
there also is no such a flag to set up the prefered encoding inside the mailto: link.
answer to this question: its impossible to detect or set the mail clients encoding so you should switch to characters that would work in every ansi table.
as alternative you could provide two links. one encoded with utf-8 with a note that, if it will display weird, the user might use the second mailto link.
or.. you provide one mailto link aswell as a drop down box to select encoding. (including a brief description of what encoding is as hover ontop of the dropdown)
It depends on the characters you want to use and your clients setups...
it may be Windows1250 ( http://en.wikipedia.org/wiki/Windows-1250 )
So, on G+ I was pointed to answer on other thread -https://stackoverflow.com/a/1831416/1190066. It seems like that different charsets fails on some combinations of browser/OS/email client. That nothing works on everything.
So I'll use the fact that it's intarnet app and it's Win 7, Chrome, Outlook 2007 setup and I'll convince admin to enable "Enable UTF-8 support for mailto: protocol." by registry key change on client company computers. - https://social.technet.microsoft.com/Forums/en-US/183b2442-6750-4e18-b61d-d87ce5f3aac3/outlook-2007-utf8-mailto-protocol-how-to-set-this-parameter-in-thousand-machines-?forum=officesetupdeploylegacy
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\Protocols\Mailto
UTF8Encoding
The value “1” turn on the “Enable UTF-8 support for mailto: protocol”
The value “0” turn off
But this workround is viable only when you can modify settings of all client's computer.
So I was looking for posibilities that don't include that change. But I see that they arent.
It's happening in
- Samsung Galaxy Note3 & 4
- Google Chrome browser V39.XX
I am using a link and when click it's launch the mail client
href="mailto:info#gmail.com?subject=Network%20issue"
result: subject=Network+issue
How to remove the plus(+) sign?
Your original approach should work... The only reason that comes to mind behind it not working is perhaps encodings are being mixed up along the way? Take a look at these threads to get a better idea of what I mean:
mailto special characters
Special characters in UTF8 mailto: subject= link and Outlook
I experimented with the base64 approach that is the answer in the second link but was unable to remedy the issue :-\ I tested this on Gmail, Inbox, and Mailbox - all with the same results as what you are describing above.
Maybe something is getting messed up at the Android layer in terms of how the link is being handed off to the mail client of your choice?
If you're rendering using Javascript, try encoding as a URL using encodeURIComponent
const urlEncoded = encodeURI(mailToLink);
before you pass the URL to the mailTo link. Otherwise encode it in the backend first.
This can be done with email addresses that contain special characters too.
Im trying to send a pre-populated email using mailto and href however I soon discovered that IE9 has a problem with recognising hrefs longer than 509 character (give or take). Basically, clicking on the link brings up a blank page. I looked for an answer and came across this javascript solution, however it still doesnt work.
Here is the anchor tag:
Sign up
And here is the script:
var sMailto = "mailto:blah#email.com?body=Dear eyecare professional,%0A%0aTo help us schedule your upcoming webinar, please fill out and return the following information:%0A%0A• Name:%0A%0A• Preferred date of webinar* (any Wednesday at 6 pm EST):%0A%0A• City/State (Optional):%0A%0A• Comments/Questions/Feedback:%0A%0AUpon receipt, we will send you a link to an upcoming GoTo Meeting webinar on Macula Risk implementation in your clinic. These webinars are regularly held on Wednesdays at 6 pm EST.%0A%0A* If you would like to request training on any other date or time - please note this in the Comments section and we will do our best to accommodate your request.%0A%0AKind Regards,%0A%0AGerry Bruckheimer";
function doMailto() {
document.location.href= sMailto;
}
The weird thing is that this works in every other browser except stupid IE 9.
UPDATE: If you are experiencing a similar problem to mine, try using window.open(url). I realise its not a perfect solution but it works.
The URL limit for IE9 is actually quite high at between 5120 and 5150 when following a link. Unfortunately a Javascript hack won't help here - the limit will still be in effect. I doubt that's the issue though.
The message you're sending contains some characters that I wouldn't put in a URL, particularly "•". You should URL encode your message before putting it in a link (that last symbol encodes to %e2%80%a2 apparently). You can URL encode it in Javascript or manually encode it with an online tool before pasting it into the <a> tag.
Some browsers are more relaxed than others in handling strange characters in URL (or in code in general).
Hope that helps