Creating a new message |
To create a new MIME message use any of com.jscape.inet.mime.MimeMessage constructors.
Example
The example below demonstrates creating a new empty MIME message.
// create new empty MimeMessage MimeMessage msg = new MimeMessage();
Example
The example below demonstrates creating a MimeMessage from existing MIME content.
String filename = "message.txt";
// buffer to hold message data byte[] data = null; try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); DataInputStream din = new DataInputStream( new FileInputStream(new File(filename))); int b = 0; while ((b = din.read()) != -1) { bout.write(b); } data = bout.toByteArray(); din.close(); } catch (Exception e) { e.printStackTrace(); }
// construct new MimeMessage from existing data MimeMessage msg = new MimeMessage(data);
|