using mailto: body limit

A

Andrew Poulos

I'm using the following code to fill an email for the user to send:

var t = escape(t); // to
var s = escape(s); // subject
var b = escape(b); // body

var doc = "mailto:" + t + "?subject=" + s +"&body=" + b;
window.location = doc;

If works fine until the length of 'b' gets over about 255 character,
then I get an "invalid syntax" error at the last line. Is there a limit
on the size of the body text for an email in this case?

Andrew Poulos
 
B

Bart Van der Donck

Andrew said:
var t = escape(t); // to
var s = escape(s); // subject
var b = escape(b); // body

var doc = "mailto:" + t + "?subject=" + s +"&body=" + b;
window.location = doc;

If works fine until the length of 'b' gets over about 255 character,
then I get an "invalid syntax" error at the last line. Is there a
limit on the size of the body text for an email in this case?

I think it's not the size of your 'b'-variable that matters, but the
size of the total URI; in your case, the 'doc'-variable. As per my
test on Vista MSIE 7.0.6. and FireFox 2.0.0.12., I don't see any
problems here as long as the full URI remains below 2K. Probably this
is enforced by the email client (in my case Windows Mail 6.0.6.) and
not by the browser.

Allowed URI size in Windows:
http://support.microsoft.com/kb/208427

On the other hand, http://www.ietf.org/rfc/rfc2068.txt advises maximum
backwards compatibility, quote:

| Servers should be cautious about depending on URI lengths above
| 255 bytes, because some older client or proxy implementations
| may not properly support these lengths.

Maybe some email clients could block after a certain URI-length too. I
wouldn't rely on mailto-protocols over 255 under production conditions
anyhow.

Hope this helps,
 
S

Stevo

Bart said:
I think it's not the size of your 'b'-variable that matters, but the
size of the total URI; in your case, the 'doc'-variable. As per my
test on Vista MSIE 7.0.6. and FireFox 2.0.0.12., I don't see any
problems here as long as the full URI remains below 2K. Probably this
is enforced by the email client (in my case Windows Mail 6.0.6.) and
not by the browser.
Allowed URI size in Windows:
http://support.microsoft.com/kb/208427

The escape will significantly increase the size too. In this case I'd
add an alert with the length of the string just before trying to use it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,175
Latest member
Vinay Kumar_ Nevatia
Top