gpt4 book ai didi

java - 使用 java 将电子邮件转换为其原始格式

转载 作者:搜寻专家 更新时间:2023-11-01 01:08:27 25 4
gpt4 key购买 nike

到目前为止,我尝试使用 JavaMail api 创建类型为 MimeMessage 的对象,然后获取其原始表示,但没有成功。我唯一可以获得的是电子邮件内容的原始表示,但不包括 header 、主题或收件人。我对任何建议、任何 Java 库都感兴趣,它们可以帮助我创建一个电子邮件对象,然后获得它的原始表示。原始表示应如下所示:

received: from imta14.emeryville.ca.mail.myisp.net ([nn.nn.30.46])
by alnrmxc19.isp.net (alnrmxc19) with ESMTP
id <20080930215116a19007q9u6e>; Tue, 30 Sep 2008 21:51:16 +0000
X-Originating-IP: [nn.nn.30.46]
Received: from libertatea.go ([nn.nn.161.160])
by IMTA14.mail.isp.net with isp
id M9qy1a00V3TwUto0E9rELB; Tue, 30 Sep 2008 21:51:15 +0000
X-Authority-Analysis: v=1.0 c=1 a=DZlucjOqAY8A:10 a=mnGO974OAAAA:8
a=9MJFf195B83LjESASTQA:9 a=Lm7NQ261g8eJHgoaELoA:7
a=7Narey355jFQWZRww2lj1r9-lCkA:4 a=8COHQAuY8ZYA:10 a=zEVpGHA-kecA:10
a=37WNUvjkh6kA:10
Received: by libertatea.go id hm1nfa0di0sn for <xxx@myisp.net>; Sun,30 Sep 2018 09:36:35
+0300 (envelope-from <Hometown.Quotes_ary@mousemegadot.com>)
Message-ID: <79864795@mousemegadot.com>
Date: Sun, 30 Sep 2018 09:36:35 +0300
From: "Hometown Quotes" <Hometown.Quotes_ary@mousemegadot.com>
To: dummy@myisp.net
Subject: Find Affordable Auto Insurance Today
MIME-Version: 1.0
X-UID: 79864795.modhnrfo.jhhnk.1
Content-Type: multipart/alternative; boundary="0-1411506895-1200484069=:66653"
Content-Transfer-Encoding: 8bit
X-PMFLAGS: 570966272 9 1 PE71PYHD.CNM
X-UC-Weight: [# ] 51
X-CC-Diagnostic: Test 'LazyHTML Tolerant' (51)

--0-1411506895-1200484069=:66653
Content-Type: text/plain; charset=iso-8859-1
Content-Transfer-Encoding: 8bit

--0-1411506895-1200484069=:66653
Content-transfer-encoding: 8bit
Content-Type: text/html; charset=iso-8859-1; DelSp="Yes"; format="flowed"

最佳答案

您要找的是MimeMessag#writeTo它将消息输出为 RFC 822 格式流。

使用 writeToMimeMessage 转换为字符串的示例。

MimeMessage mimeMessage;

// mimeMessage get assigned

ByteArrayOutputStream output = new ByteArrayOutputStream();
mimeMessage.writeTo(output);
String rawEmail = output.toString();

关于java - 使用 java 将电子邮件转换为其原始格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12604420/

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