I try to send a SMIME signed multipart mail. One part is text, the other is an attached file.
I started with the sample CreateSignedMultipartMail from BouncyCastle.
There are 2 bodyparts - but both are text. I need one text and one file-attachment.
Works like a charm as long I keep it with the text bodyparts. If I change one of the bodyparts to a file I get a validation-error in the receiving mail-client.
MimeBodyPart msg2 = new MimeBodyPart();
//msg2.setText("Hello part 2!");
msg2.attachFile (new File ("my.txt"));
The only way I got rid of the validation-problem was this (set to B64 encoding).
MimeBodyPart msg2 = new MimeBodyPart();
mbpatt.attachFile(new File ("pom.xml"), null, "base64");
I expect the problem to be somewhere in a canonicalize of the parts and so it removes whitespace-chars - but not sure about that.
Is there an official recommendation how to handle file attachments in BC with SMIME?