Im trying to send raw emails with images as attachments stored in s3 using I am trying to send raw emails with images as attachments stored in s3 using java. However, when receiving email images are corrupted. I tried using file stored in my disk and it worked correctly but it's not working for files stored in S3. Here's the code I'm using.
MimeBodyPart att = new MimeBodyPart();
att.setFileName(attachment.getFileName());
String attContent = s3.getObjectAsString(emailServiceConfiguration.getAttachmentS3Bucket(), attachment.getPath());
DataSource source = new ByteArrayDataSource(attContent.getBytes(),"application/png");
att.setDataHandler(new DataHandler(source));
msg.addBodyPart(att);
Please help, I am stuck here for quite some time.