public class TNEFMime
extends java.lang.Object
TNEFMime
class provides high-level utility methods to access
TNEF streams and extract their contents, using the JavaMail API.
Note: This class is experimental and is intended to show possible uses of the
Java TNEF package.Constructor and Description |
---|
TNEFMime() |
Modifier and Type | Method and Description |
---|---|
protected static void |
addTextPart(javax.mail.Multipart mp,
java.lang.String text,
java.lang.String contentType)
Adds a text part to the given multipart, with the given text and content
type, using the UTF-8 encoding (and utf-8 charset parameter).
|
static TNEFMimeMessage |
convert(javax.mail.Session session,
Message message)
Constructs a TNEFMimeMessage from the given TNEF Message.
|
static javax.mail.internet.MimeMessage |
convert(javax.mail.Session session,
javax.mail.internet.MimeMessage message)
Converts TNEF parts within given message to MIME-structured parts
(recursively).
|
static javax.mail.internet.MimeMessage |
convert(javax.mail.Session session,
javax.mail.internet.MimeMessage message,
boolean embed)
Converts TNEF parts within given message to MIME-structured parts
(recursively).
|
static javax.mail.Part |
convert(javax.mail.Session session,
javax.mail.Part part)
Converts TNEF parts within given part to MIME-structured parts (recursively).
|
static javax.mail.Part |
convert(javax.mail.Session session,
javax.mail.Part part,
boolean embed)
Converts TNEF parts within given part to MIME-structured parts (recursively).
|
static TNEFMimeMessage |
convert(javax.mail.Session session,
TNEFInputStream in)
Constructs a TNEFMimeMessage from the given TNEFInputStream.
|
static boolean |
extractTNEF(javax.mail.Part part,
java.lang.String tnefFilename)
Extracts a TNEF attachment from a specified message Part (recursively).
|
static boolean |
extractTNEF(java.lang.String mimeFilename,
java.lang.String tnefFilename)
Extracts a TNEF attachment from a specified MIME file.
|
static void |
main(java.lang.String[] args)
Main entry point for command-line utility.
|
public static boolean extractTNEF(java.lang.String mimeFilename, java.lang.String tnefFilename) throws java.io.IOException, javax.mail.MessagingException
mimeFilename
- the filename of a file containing a MIME messagetnefFilename
- the filename of a file to which the TNEF attachment
extracted from the MIME message should be writtenjava.io.IOException
- if an I/O error occursjavax.mail.MessagingException
- if an error occurs while accessing a mime partpublic static boolean extractTNEF(javax.mail.Part part, java.lang.String tnefFilename) throws java.io.IOException, javax.mail.MessagingException
part
- a message Part which may contain a TNEF attachment or
additional partstnefFilename
- the filename of a file to which the TNEF attachment
extracted from the Part should be writtenjava.io.IOException
- if an I/O error occursjavax.mail.MessagingException
- if an error occurs while accessing a mime partprotected static void addTextPart(javax.mail.Multipart mp, java.lang.String text, java.lang.String contentType) throws javax.mail.MessagingException
mp
- the multipart to add the text totext
- the text to addcontentType
- the full text mime typejavax.mail.MessagingException
- if an error occurs while accessing a mime partpublic static TNEFMimeMessage convert(javax.mail.Session session, TNEFInputStream in) throws java.io.IOException, javax.mail.MessagingException
session
- the session used to handle the MimeMessagein
- the TNEFInputStream containing message to convertjava.io.IOException
- if an I/O error occursjavax.mail.MessagingException
- if an error occurs while accessing a mime partpublic static TNEFMimeMessage convert(javax.mail.Session session, Message message) throws java.io.IOException, javax.mail.MessagingException
session
- the session used to handle the MimeMessagemessage
- the Message to convertjava.io.IOException
- if an I/O error occursjavax.mail.MessagingException
- if an error occurs while accessing a mime partpublic static javax.mail.internet.MimeMessage convert(javax.mail.Session session, javax.mail.internet.MimeMessage message) throws java.io.IOException, javax.mail.MessagingException
session
- a Session instance used in creating new Partsmessage
- the MIME message to convertjava.io.IOException
- if an I/O error occursjavax.mail.MessagingException
- if an error occurs while accessing a mime partpublic static javax.mail.internet.MimeMessage convert(javax.mail.Session session, javax.mail.internet.MimeMessage message, boolean embed) throws java.io.IOException, javax.mail.MessagingException
session
- a Session instance used in creating new Partsmessage
- the MIME message to convertembed
- if true, the messages obtained from converted TNEF parts are
embedded in the message in place of the TNEF parts. If false,
the first TNEF part encountered is converted to a mime message
and returned.java.io.IOException
- if an I/O error occursjavax.mail.MessagingException
- if an error occurs while accessing a mime partpublic static javax.mail.Part convert(javax.mail.Session session, javax.mail.Part part) throws java.io.IOException, javax.mail.MessagingException
session
- a Session instance used in creating new Partspart
- the MIME part to convertjava.io.IOException
- if an I/O error occursjavax.mail.MessagingException
- if an error occurs while accessing a mime partpublic static javax.mail.Part convert(javax.mail.Session session, javax.mail.Part part, boolean embed) throws java.io.IOException, javax.mail.MessagingException
session
- a Session instance used in creating new Partspart
- the MIME part to convertembed
- if true, the messages obtained from converted TNEF parts are
embedded in the part in place of the TNEF parts. If false, the
first TNEF part encountered is converted to a mime message and
returned.java.io.IOException
- if an I/O error occursjavax.mail.MessagingException
- if an error occurs while accessing a mime partpublic static void main(java.lang.String[] args)
args
- the command-line argumentsCopyright © 2021. All Rights Reserved.