{
SMIMECompressedGenerator cgen = new SMIMECompressedGenerator();
ByteArrayOutputStream bOut1 = new ByteArrayOutputStream();
ByteArrayOutputStream bOut2 = new ByteArrayOutputStream();
MimeBodyPart cbp = cgen.generate(msg, SMIMECompressedGenerator.ZLIB);
SMIMECompressedParser sc = new SMIMECompressedParser(cbp);
msg.writeTo(bOut1);
InputStream in = sc.getContent().getContentStream();
int ch;
while ((ch = in.read()) >= 0)
{
bOut2.write(ch);