javamail MimeBodyPart.SetFileName() makes image weird java

42 Views Asked by At

I'm trying to attach images using javamail to a mail but it calls it "noname" by default, so I used .setFileName("name") but it results in the image being weirdly displayed on a black background instead of a transparent one, and the whole image get black Here's the code I used:

ImageSources = new MimeBodyPart();
                DataSource LogoDataSource = new FileDataSource(System.getenv("APPDATA")+"\\Leonard\\Logo-Terre-Happy.bmp");
                ImageSources.setDataHandler(new DataHandler(LogoDataSource));
                ImageSources.addHeader("Content-ID", "<logo>");
                ImageSources.setFileName("logo.bmp");
                multipart.addBodyPart(ImageSources);

Thanks for any help

1

There are 1 best solutions below

0
On

Turns out the issue was that my images were in bmp and I had to convert them in png in order to make it work