gpt4 book ai didi

java - MimeMessage 内容传输编码问题

转载 作者:行者123 更新时间:2023-11-30 05:04:42 26 4
gpt4 key购买 nike

大家好...我希望有人能给我一些关于我遇到的问题的线索。

阅读 MimeMessage 的 getInputStream() 的 Javadoc,它说“返回此消息内容的已解码输入流”然而,这不是我所经历的。输出未解码。例如,如果我有一条消息,则如下

Date: Wed, 24 Feb 2010 11:29:13 +1100
From: xxxxxxxxx
To: xxxxxxxxxxxx
Message-ID: <4B8472D9.5050901@xxxxxxxxx>
Subject: xxxxxxxxxxxxxxxxxx
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="------------000801030004000206000901"
Content-Transfer-Encoding: quoted-printable
Organization: xxxxxxxxxxxxxxxxxx
User-Agent: Thunderbird 2.0.0.23 (Windows/20090812)

This is a multi-part message in MIME format.
--------------000801030004000206000901
Content-Type: text/plain; charset=3DISO-8859-1; format=3Dflowed
Content-Transfer-Encoding: 7bit

!

--------------000801030004000206000901
Content-Type: text/plain;
name=3D"bla.bla"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline;
filename=3D"bla.bla"

my.username =3D holly
my.host =3D molly
--------------000801030004000206000901--

然后,假设我有一个用上述内容构造的名为“m”的对象,然后调用 m.getInputStream() 并将输出转储到屏幕上显示那些“=3D”字符集。我做错了什么?

如果我使用 QPDecoderStream 来解码 m.getInputStream() 的输出,那么结果当然是正确的。然而,它达不到目的,因为 Javadoc 说 getInputStream() 返回一个已解码的输入流。

最佳答案

此处的问题是消息格式错误。 You're not allowed to set Content-Transfer-Encoding to quoted-printable on a multipart part :

If a Content-Transfer-Encoding header field appears as part of amessage header, it applies to the entire body of that message. If aContent-Transfer-Encoding header field appears as part of an entity'sheaders, it applies only to the body of that entity. If an entity isof type "multipart" the Content-Transfer-Encoding is not permitted tohave any value other than "7bit", "8bit" or "binary".

您可能可以获取顶级 MimeMessage 的解码内容流并从中实例化 MimeMultipart,但这只是解决了损坏消息的基本问题.

关于java - MimeMessage 内容传输编码问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5493735/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com