发送包含任何这些附件,htmlbody,内联图片或所有这些内容的mime消息? [英] Sending mime message containing any of these attachment,htmlbody ,inline image or all of them?

查看:280
本文介绍了发送包含任何这些附件,htmlbody,内联图片或所有这些内容的mime消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

据我所知,我的电子邮件应用程序仅支持包含附件的纯文本。如果附件列表为空,我以简单的方式处理它,
只是发送mime消息,如果attchment列表不为null,我正在为每个附件创建正文部分,为正文创建一个。在multipart中添加
,设置为mime消息。

As of know my email application was supporting only plain text with attachments. I was handling it in a simple way if attachment list is null, simply send the mime message and if attchment list is not null, i was creating body part for each attachment and one for body. Adding them in multipart which is set in to mime message.

但现在需要支持html部分和内嵌图像(图像将作为附件发送
和html正文将引用)​​。我知道基础知识mime即如何为每个哑剧类型创建身体部位。但实际上我没有得到
如何在运行时创建身体部位当我不知道身体和附件列表将包含什么。例如,body只能包含简单的
文本或带有附件的html正文或html正文或带有附件的内嵌图像或带附件的普通图像的html正文。

But now need to support the html part and inline images(where images will be sent as attachment and html body will be referreing).I know the basics of mime i.e how to create the body parts for each mime type. But really i am not getting how to create the body parts at run timw when i do not what body and attachment list will contain. For example body can contain only plain text or html body or html body with attachment or html body with inline image with attachment or plain body with attchment.

坦率地说,我没有得到
如何处理上述permations和组合的电子邮件主体和附件列表。(例如,有时我需要创建最高
消息作为multipart / mixed包含身体部位作为mulipart / alternative和另一个身体部分plain,bla bla ....)。 是否有基于正文内容和附件列表处理这些所有方案的标准
代码。请指出正确的方向?

Frankly i am not getting how to process the emailbody and attachment list for above mentioned permuations and combinations.(for example some time i need to create top message as multipart/mixed containg body parts as mulipart/alternative and another body part plain, bla bla....). Is there standard code handling these all scenarios based on body content and attachment list. Please point me in right direction?

这里是旧的方法签名,它只支持带附件的纯文本

here is the old method signature which was supporting only plain text with attachments

  public void sendMimeEmail(List toMailAddresses,
  String fromMailAddress,   String body, List<AttachmentData> attachments) {}


推荐答案

我认为这里没有任何魔力。您只需要足够的if语句来涵盖案例。

I don't think there's any magic here. You just need enough "if" statements to cover the cases.

这篇关于发送包含任何这些附件,htmlbody,内联图片或所有这些内容的mime消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆