gpt4 book ai didi

java - 如何在 JavaMail(标准电子邮件)中嵌套 MimeBodyParts?

转载 作者:搜寻专家 更新时间:2023-11-01 01:55:54 26 4
gpt4 key购买 nike

我正在尝试使用 JavaMail 发送包含嵌入/内联图像的 html 电子邮件(带有替代文本)。

我想看看格式正确的邮件是什么样子的,所以我使用带有内联图像的 gmail 发送了一封邮件,下面是原始来源。看起来好像他们在消息中嵌套 body 部位。我怎样才能使用 javamail 准确地复制它。我找不到将一个 Multipart 放入另一个 Multipart 的方法。

MIME-Version: 1.0 Received: by 10.50.75.3 with HTTP; Thu, 23 Feb 2012 20:15:34 -0800 (PST) Date: Thu, 23 Feb 2012 20:15:34 -0800 Delivered-To: x@gmail.com Message-ID: Subject: c From: Foo Bar To: Foo Bar Content-Type: multipart/related; boundary=e89a8f3b9b051e124104b9ae03fb

--e89a8f3b9b051e124104b9ae03fb Content-Type: multipart/alternative; boundary=e89a8f3b9b051e123604b9ae03fa

--e89a8f3b9b051e123604b9ae03fa Content-Type: text/plain; charset=ISO-8859-1

plain text content goes here

--e89a8f3b9b051e123604b9ae03fa Content-Type: text/html; charset=ISO-8859-1


--e89a8f3b9b051e123604b9ae03fa-- --e89a8f3b9b051e124104b9ae03fb Content-Type: image/png; name="logo.png" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: ii_135ad92205fc1ace

iVBORw0KGgoAAAANSUhEUgAAACgAAAAoCAYAAACM/rhtAAAAh0lEQVR42u3ZsQnAIBBGYVtHShVI 7ViprASXcw8HMCckEGyTkB98xWsE4WvOwnMhBG/tVrGaSOU0+Q5MVhMtdWAVBlY3HCyW+7nlbhqB TiGAAAECBAhwMqB0AN8ANuUkgQzJvEPy1WP75C5AgAABAgQ4GXATAK4DUP8LOAsD87WGiIJriGj5 AwiiiyDxmymtAAAAAElFTkSuQmCC --e89a8f3b9b051e124104b9ae03fb--

更新:

使用标准的多部分内联图像方法(如 lechlukasz 链接的方法)生成以下电子邮件,这不是我需要的:

MIME-Version: 1.0 Received: by 10.236.146.106 with SMTP id q70mr1894063yhj.0.1330071158663; Fri, 24 Feb 2012 00:12:38 -0800 (PST) Reply-To: Foo Bar Message-ID: <20cf303bfc80f02cfa04b9b152db@google.com> Date: Fri, 24 Feb 2012 08:12:38 +0000 Subject: please oh please4 From: Foo Bar To: Foo Bar Content-Type: multipart/alternative; boundary=20cf303bfc80f02ce704b9b152d6

--20cf303bfc80f02ce704b9b152d6 Content-Type: text/plain; charset=UTF-8; format=flowed; delsp=yes Content-Transfer-Encoding: base64

77+9UE5HDQoaDQoAAAANCklIRFIAAAAoAAAAKAgGAAAA77+977+977+9bQAAAO+/vUlEQVR477+9 77+977+977+9Ce+/vSAgDQoQRmFbR0oVSO+/vVjvv73vv70E77+9cw8HMCckEGzvv73vv70ffO+/ vWsE77+9a++/ve+/vXMhBG/vv71W77+977+9SO+/vTTvv70OTFYTLXVgFQZWNxws77+977+977+9 77+9bhrvv71OIe+/vQABAgQIcDLvv710AO+/vQA277+9JO+/vQzvv73vv71D77+977+9Y++/ve+/ vS5A77+9AAECBDgZcBMA77+9A1Dvv70LOAsD77+977+977+977+977+9a++/vWjvv70DCO+/ve+/ vSDvv73vv70p77+9AAAAAElFTkTvv71CYO+/vQ0K --20cf303bfc80f02ce704b9b152d6 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

--20cf303bfc80f02ce704b9b152d6--

最佳答案

您可以通过创建 MimeBodyPart 将一个 Multipart 放入另一个 Multipart,将其内容设置为 Multipart,然后将该正文部分添加到第一个 Multipart。

关于java - 如何在 JavaMail(标准电子邮件)中嵌套 MimeBodyParts?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9427134/

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