Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Apple或Mac Mail会打开所有附件图像,即使它们已嵌入_Java_Ios_Email_Mime - Fatal编程技术网

Java Apple或Mac Mail会打开所有附件图像,即使它们已嵌入

Java Apple或Mac Mail会打开所有附件图像,即使它们已嵌入,java,ios,email,mime,Java,Ios,Email,Mime,当我们从tomcat服务器发送电子邮件时,它实现了MimeMultiPart,在大多数邮件软件中都能正常打开,例如Gmail、Outlook和Android mail。 但当它在Apple Mail上打开时,它会自动打开PDF和图像,这在手机(手机和平板电脑,因为笔记本电脑可以在命令中更改)中是永久性的 正如我在几个网站上读到的那样,这就是它为苹果设计的方式。 问题是,即使是嵌入的,据说是隐藏的附件,也会显示出来。 这会产生双重图像,我们称之为邮件中通过html嵌入的图像 图像是一个徽标,所以它

当我们从tomcat服务器发送电子邮件时,它实现了MimeMultiPart,在大多数邮件软件中都能正常打开,例如Gmail、Outlook和Android mail。 但当它在Apple Mail上打开时,它会自动打开PDF和图像,这在手机(手机和平板电脑,因为笔记本电脑可以在命令中更改)中是永久性的

正如我在几个网站上读到的那样,这就是它为苹果设计的方式。 问题是,即使是嵌入的,据说是隐藏的附件,也会显示出来。 这会产生双重图像,我们称之为邮件中通过html嵌入的图像

图像是一个徽标,所以它总是通过电子邮件发送。我希望有一个不同的协议,我可以使用,也适用于苹果邮件。我还没有在网络上看到类似的问题,所以我希望我们只是使用一些不同的协议

    BodyPart messageBodyPart = new MimeBodyPart();
    String htmlText = message + "<img src=\"cid:image123\">";
    messageBodyPart.setContent(htmlText, "text/html; charset=UTF-8");

    MimeMultipart mp = new MimeMultipart("mixed");
    mp.addBodyPart(messageBodyPart);

    BodyPart imageBodyPart = new MimeBodyPart();
    String file = this.getClass().getClassLoader().getResource("images/Logo.gif").getFile();
    DataSource fds = new FileDataSource(file);
    imageBodyPart.setFileName("Logo.gif");
    imageBodyPart.setHeader("Content-ID","<image123>");
    imageBodyPart.setDisposition(Part.INLINE);

    mp.addBodyPart(imageBodyPart);
BodyPart messageBodyPart=new MimeBodyPart();
字符串htmlText=消息+“”;
setContent(htmlText,“text/html;charset=UTF-8”);
MimMultipart mp=新的MimMultipart(“混合”);
mp.addBodyPart(messageBodyPart);
BodyPart imageBodyPart=新的MimeBodyPart();
字符串文件=this.getClass().getClassLoader().getResource(“images/Logo.gif”).getFile();
DataSource fds=新文件DataSource(文件);
setFileName(“Logo.gif”);
setHeader(“内容ID”,即“”);
imageBodyPart.setDisposition(Part.INLINE);
mp.addBodyPart(图像BodyPart);

当我删除HTML代码时,它仍然会在Apple mail中显示附加的图像,但是,它不会在其他电子邮件软件中完全显示。

我以前也见过这种行为,我记得这是由于iOS设备上MIME头解析逻辑的不同

另一篇文章(以及相应的答案)提及并应指导您找到一个可行的解决方案:


祝你好运,请告诉我们你进展如何。

我以前也见过这种行为,我记得这是由于iOS设备上的MIME头解析逻辑不同造成的

另一篇文章(以及相应的答案)提及并应指导您找到一个可行的解决方案:


祝你好运,请让我们知道你进展如何。

缺陷终于开始生产了。 MIME结构略有变化,以

我所做的就是建造

  • 混合的+
    • 相关的+
    • html
    • 内联图像
  • 附件:
  • 附件:
由于某种原因,在撰写本文时,Yahoo online client并没有显示附件,所以省略了带有附件的备选方案。把它们混在一起很好

经过测试和使用

  • 苹果/IOS邮件(平板电脑Ipad 2)
  • Outlook Windows 7客户端
  • Outlook mobile(Android)
  • Gmail网络客户端
  • Gmail手机(Android)
  • Android移动电子邮件(棒棒糖)
  • 雅虎网络客户端
  • 雅虎移动电子邮件(安卓)
  • Lotus Notes Windows 7客户端
注:Android使用的是三星Note4棒棒糖

代码:

BodyPart messageBodyPart=new MimeBodyPart();
字符串htmlText=消息+“”;
setContent(htmlText,“text/html;charset=UTF-8”);
MimMultipart mpRelated=新的MimMultipart(“相对”);
mpRelated.addBodyPart(messageBodyPart);
BodyPart imageBodyPart=新的MimeBodyPart();
字符串文件=this.getClass().getClassLoader().getResource(“images/Logo.gif”).getFile();
DataSource fds=新文件DataSource(文件);
setFileName(“Logo.gif”);
setHeader(“内容ID”,即“”);
imageBodyPart.setDisposition(Part.INLINE);
mpRelated.addBodyPart(imageBodyPart);
MimMultipart mpMixed=新的MimMultipart(“混合”);
//巢相关成混合型
BodyPart relatedInMixed=新的MimeBodyPart();
相关的混合设置内容(mpRelated);
mpMixed.addBodyPart(relatedInMixed);
//TODO将附件添加到mpMixed

缺陷终于在生产过程中出现了。 MIME结构略有变化,以

我所做的就是建造

  • 混合的+
    • 相关的+
    • html
    • 内联图像
  • 附件:
  • 附件:
由于某种原因,在撰写本文时,Yahoo online client并没有显示附件,所以省略了带有附件的备选方案。把它们混在一起很好

经过测试和使用

  • 苹果/IOS邮件(平板电脑Ipad 2)
  • Outlook Windows 7客户端
  • Outlook mobile(Android)
  • Gmail网络客户端
  • Gmail手机(Android)
  • Android移动电子邮件(棒棒糖)
  • 雅虎网络客户端
  • 雅虎移动电子邮件(安卓)
  • Lotus Notes Windows 7客户端
注:Android使用的是三星Note4棒棒糖

代码:

BodyPart messageBodyPart=new MimeBodyPart();
字符串htmlText=消息+“”;
setContent(htmlText,“text/html;charset=UTF-8”);
MimMultipart mpRelated=新的MimMultipart(“相对”);
mpRelated.addBodyPart(messageBodyPart);
BodyPart imageBodyPart=新的MimeBodyPart();
字符串文件=this.getClass().getClassLoader().getResource(“images/Logo.gif”).getFile();
DataSource fds=新文件DataSource(文件);
setFileName(“Logo.gif”);
setHeader(“内容ID”,即“”);
imageBodyPart.setDisposition(Part.INLINE);
mpRelated.addBodyPart(imageBodyPart);
MimMultipart mpMixed=新的MimMultipart(“混合”);
//巢相关成混合型
BodyPart relatedInMixed=新的MimeBodyPart();
相关的混合设置内容(mpRelated);
mpMixed.addBodyPart(relatedInMixed);
//TODO将附件添加到mpMixed

我认为零是一种特殊的性格。。。我将尝试将其设置为空或空白。不起作用,只是将配置留空。它在Gmail和Outlook中仍然运行良好。但IOS邮件不太稳定,有时徽标会显示b
    BodyPart messageBodyPart = new MimeBodyPart();
    String htmlText = message + "<img src=\"cid:image123\">";
    messageBodyPart.setContent(htmlText, "text/html; charset=UTF-8");

    MimeMultipart mpRelated = new MimeMultipart("relative");
    mpRelated.addBodyPart(messageBodyPart);

    BodyPart imageBodyPart = new MimeBodyPart();
    String file = this.getClass().getClassLoader().getResource("images/Logo.gif").getFile();
    DataSource fds = new FileDataSource(file);
    imageBodyPart.setFileName("Logo.gif");
    imageBodyPart.setHeader("Content-ID","<image123>");
    imageBodyPart.setDisposition(Part.INLINE);

    mpRelated.addBodyPart(imageBodyPart);

    MimeMultipart mpMixed = new MimeMultipart("mixed");
    //Nest Related into mixed
    BodyPart relatedInMixed = new MimeBodyPart();
    relatedInMixed.setContent(mpRelated);
    mpMixed.addBodyPart(relatedInMixed);

    //TODO Add attachement to mpMixed