javascript 传递给系统调用的数据区太小”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13191015/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 18:02:02  来源:igfitidea点击:

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

javascriptemailoutlook

提问by R Chaudhary

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

Outlook 电子邮件是否有特定的字符串大小。我有以下代码给我一个错误

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.

如果我正在删除代码,则不会显示此消息。所以它接缝是与电子邮件正文中的字符数有关。请建议。

回答by kieran_delaney

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.

例如,Internet Explorer 中的最大 URL 长度为 2,083 个字符 ( MS KB Link)。如果您的链接的总长度(包括主题、地址和正文)超过了这个长度,您就会得到这个错误。

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

为了解决这个问题(因为我们必须支持 IE),我在生成链接后使用了这个 kludge:

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.

这并不完美,但在极少数情况下,用户会尝试生成大量通知电子邮件,他们会先礼貌地警告,期间提醒,事后通知。

回答by kieran_delaney

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.

它可能会失败,因为某些电子邮件客户端不接受空格作为 href 的一部分,因此您需要对它们进行 URI 编码(转义),因此它们变为 %20。

Try this:

试试这个:

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

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