java mail polling从邮件中读取内联或嵌入的图像(表情符号)

我是java邮件轮询的新手,如果用户向对方发送邮件,我会创建一种类型的会话应用程序,然后我从他们那里读取邮件并在对话中作为新邮件发布。

现在的问题是,如果有笑脸,内联或嵌入图像该怎么办。 例如在gmail邮件中我们也可以发送表情符号,现在如何阅读那个微笑并发布到页面上。 请给我一些适当的解决方案。

这种类型的表情。

我找到了从邮件中下载内嵌图像+图标的解决方案。

private String getAttachments(Message message, HttpServletRequest request) throws MessagingException, IOException { String contentType = message.getContentType(); String attachFiles=""; if (contentType.contains("multipart")) { // content may contain attachments Multipart multiPart = (Multipart) message.getContent(); int numberOfParts = multiPart.getCount(); for (int partCount = 0; partCount < numberOfParts; partCount++) { MimeBodyPart part = (MimeBodyPart) multiPart.getBodyPart(partCount); String disposition =part.getDisposition(); String file=part.getFileName(); //External attachments if (disposition != null && Part.ATTACHMENT.equalsIgnoreCase(disposition)) { // this part is attachment String fileName = new Date().getTime()+ "_"+ part.getFileName().replaceAll("[^a-zA-Z0-9\\._]+", "_"); //To make attachment name uniq we are adding current datatime before name. attachFiles += fileName + ","; //concrete all attachment's name with comma separated. part.saveFile(new File(request .getSession() .getServletContext() .getRealPath( "/WEB-INF/attechments/" + fileName))); //To save the attachment file at specific location. // LOG.info("\n\t Path :- " +request.getSession().getServletContext().getRealPath("/WEB-INF/attechments/" + fileName)); } //Inline Attachments else if (disposition != null && Part.INLINE.equalsIgnoreCase(disposition)) { // this part is attachment String fileName = new Date().getTime()+ "_"+ part.getFileName().replaceAll("[^a-zA-Z0-9\\._]+", "_"); //To make attachment name uniq we are adding current datatime before name. // attachFiles += fileName + ","; //concrete all attachment's name with comma separated. part.saveFile(new File(request .getSession() .getServletContext() .getRealPath( "/WEB-INF/attechments/" + fileName))); //To save the attachment file at specific location. // LOG.info("\n\t Path :- " +request.getSession().getServletContext().getRealPath("/WEB-INF/attechments/" + fileName)); } //Inline icons and smileys else if(file != null && disposition==null) { String fileName = new Date().getTime()+ "_"+ part.getFileName().replaceAll("[^a-zA-Z0-9\\._]+", "_"); // attachFiles += fileName + ","; //concrete all attachment's name with comma separated. part.saveFile(new File(request .getSession() .getServletContext() .getRealPath( "/WEB-INF/attechments/" + fileName))); } } } if (attachFiles.length() > 1) { attachFiles = attachFiles.substring(0, attachFiles.length() - 1); } return attachFiles; }