Loading email attachment contents into a mendix FileDocument using java

0
Hello Everyone, So I am trying to import a FileAttachment object from an email  using a java action into the MessageAttachment object which is a generalisation of the Mendix System.FileDocument. I am able to set the name and get the type of documents from the email but the contents of the message attachments are empty. I’ve tried several multiple ways to achieve this, also I can confirm that the attachment isn’t empty as I can see the size of the file. for (Attachment attachment : email.getAttachments()) { MessageAttachment ma = new MessageAttachment(context); FileAttachment fileAttachment = (FileAttachment)attachment; fileAttachment.load(); ma.setName(fileAttachment.getName()); ma.setMessageAttachment_MailItem(mi); byte[] bytes = fileAttachment.getContent(); ByteArrayInputStream stream = new ByteArrayInputStream (bytes); ma.setFileSize(bytes.length); ma.setContents(context, stream, bytes.length); Core.storeFileDocumentContent(context, ma.getMendixObject(), stream); } Any help would be appreciated if anyone has got any suggestions on how I can load the data onto the mendix object.
asked
0 answers