java - Can't get email attachments without extension from javax.mail.message -


Please help me to solve my problem. I have a function that looks for email content and attachments: / P>

  Public Zero Set Content and Attachments List (GMailEmail Gmail Email, Part Message) Messaging Option, IOException {If (message.isMimeType ("text / *") & amp; Amp; StringUtils.isEmpty (Message.getFileName ()) {gmailEmail.setContent (message.getContent (.) ToString ()); Log.debug ("Text Data Found. Set as Body:" + message.getContent (.) ToString ()); } And if (message.imetip type (MULTIPART_MIME_TYPE)) {multipart multipart message = (multipart) message.getContent (); For (int i = 0; i & lt; multipartMessage.getCount (); i ++) {bodypart message page = multipartMessage.getBodyPart (i); SetContentAndAttachmentsList (GmailAmail, MessagePant); }} And if (StringUtils.isNotBlank (message.getFileName ())} {MailAttachment attachments = new mailattempt (); Attachment.setContentType (message.getContentType ()); Log.debug ("Attachment content type:" + message.getContentType ()); Attachment.setName (message.getFileName ()); Log.debug ("Attachment file name:" + message.getFileName ()); If (message.getContent (example) InputStream) {attachment.setInputStream ((InputStream) message.getContent ()); } And (attachment.setInputStream (IOUtils.toInputStream (message.getContent (.toString (), UTF_8))} List & lt; Mail Attache & gt; Attachmentslist = Gmail EmailGet Attachments List (); attachmentsList.add (attachment) ); GmailEmail.setAttachmentsList ("attachmentsList"); Log.debug ("found engagement" + message.getFileName ());}}   

Gmail email is POJO if the email contains attachments that have extensions So it works perfectly but when attachments do not have any extension, message.getFileName () just clears.

I Has solved this problem.

  StringUtils.isBlank (message.getFileName ())   

instead of

  StringUtils.isEmpty should be (Message.getFileName ())   

in the second row.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -