send secure email using bouncycastle
Hi,
I need to send a digitally signed email with a pdf attachment.I am using bouncycastle for this.But I am having some problem while viewing the email sent .
1)If I set the text message(mimebodypart.setText("hello") and pdf file (using mimebodypart.setDataHandler(...))in same mimebody then the text message is missing in the email sent.
Mail sent is shown as signed with correct signature
PDF file is available as attachment and recepient is able to view it.
But Text message is missing.
2)If I set the text message and attachment file in 2 different mimebodypart objects then I am getting an error while trying the view the mail using outlook express(Canât open this item. Your Digital ID name can not be found by the underlying security system.)
SMIMESignedGenerator was used to generate the Multipart object.
My code looks like:
mimebodypart.setText("hello");
mimebodypart2.setDataHandler() ->for setting file as attachment
MimeMultipart mp= smimesignedgenerator.generate(mimebodypart,"BC");
mp.addBodyPart(mimebodypart);
mp.addBodyPart(mimebodypart2);
Can someone please help me?
Thanks in advance.
|