The data area passed to a system call is too small"

安稳与你 提交于 2020-01-14 07:12:48

问题


Is there a certain string size for outlook email. I have the following code that gives me an error

The data area passed to a system call is too small

However this only seems to occur when my message body is larger then normal

document.location.href = "mailto:" + emailAddress + "?subject=my msgs Relief&body=" + escape(message);

If I am removing code then it's not showing this message. So it seams that it's related to the number of characters in email body. Please suggest.


回答1:


I recently came across this exact problem. The issue is that different browsers (and different email clients) have limits on the amount of data that can be passed between them using mail-to links.

For example, the maximum URL length in Internet Explorer is 2,083 characters (MS KB Link). If the total length of your link including the subject, address, and body exceeds this, you will get exactly this error.

To fix this (as we have to support IE), I used this kludge after generating my link:

var mailto_link = 'mailto:'+addresses+'?subject='+subject+'&body='+body_message;
win = window.open(mailto_link.substr(0,2000),'emailWindow');

It's not perfect, but on the rare occasions the user tries to generate an enormous notification email, they are politely warned first, reminded during, and notified after the event.




回答2:


It probably fails because whitespaces not accepted by some email clients as a part of the href, so you need to URI encode (escape) them, so they become %20.

Try this:

document.location.href = "mailto:" + emailAddress + "?subject=my%20msgs%20Relief&body=" + escape(message);



来源:https://stackoverflow.com/questions/13191015/the-data-area-passed-to-a-system-call-is-too-small

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!