01: package org.bouncycastle.mail.smime.examples;
02:
03: import java.io.FileInputStream;
04: import java.util.Properties;
05:
06: import javax.mail.Session;
07: import javax.mail.internet.MimeBodyPart;
08: import javax.mail.internet.MimeMessage;
09:
10: import org.bouncycastle.mail.smime.SMIMECompressed;
11: import org.bouncycastle.mail.smime.SMIMEUtil;
12:
13: /**
14: * a simple example that reads a compressed email.
15: * <p>
16: */
17: public class ReadCompressedMail {
18: public static void main(String args[]) throws Exception {
19: //
20: // Get a Session object with the default properties.
21: //
22: Properties props = System.getProperties();
23:
24: Session session = Session.getDefaultInstance(props, null);
25:
26: MimeMessage msg = new MimeMessage(session, new FileInputStream(
27: "compressed.message"));
28:
29: SMIMECompressed m = new SMIMECompressed(msg);
30:
31: MimeBodyPart res = SMIMEUtil.toMimeBodyPart(m.getContent());
32:
33: System.out.println("Message Contents");
34: System.out.println("----------------");
35: System.out.println(res.getContent());
36: }
37: }
|