Drag and drop an email attachment that is inside the body of the email

249 views Asked by At

I am currently facing an issue with the Upload component of Vaadin v22.0.15.

I want to be able to drag and drop attachments from an Outlook email. It works perfectly if the email has been sent in HTML format.

In that case you can see the attachments at the top of the email, just under the subject. When I drag and drop one of those, the file is being correctly loaded in the MemoryBuffer.

Example image: email in HTML format

enter image description here

My problem is when the email has been sent in Rich Text Format, in which case the attachments are visible inside the body of the email.

When I try to drag and drop an attachment from an email sent in Rich Text Format the content of the file is not loaded in the MemoryBuffer. I get an empty file with the same name as the attachment.

Example image:

enter image description here

Here is some code:

myUpload.addSucceededListener(event -> {
        try {
            uploadedFileContent = memoryBuffer.getInputStream().readAllBytes(); //this returns an empty byte array when I drag and drop from the email content (as per example image 2)
        } catch (IOException e) {
            LOGGER.error("File not readable", e);
        }
    });
0

There are 0 answers