Methods Summary |
---|
public void | addHeader(java.lang.String name, java.lang.String value)Add this value to the existing values for this header_name.
Note that RFC 822 headers must contain only US-ASCII
characters, so a header that contains non US-ASCII characters
must be encoded as per the rules of RFC 2047.
headers.addHeader(name, value);
|
public void | addHeaderLine(java.lang.String line)Add a header line to this body part
headers.addHeaderLine(line);
|
public void | attachFile(java.io.File file)Use the specified file to provide the data for this part.
The simple file name is used as the file name for this
part and the data in the file is used as the data for this
part. The encoding will be chosen appropriately for the
file data.
FileDataSource fds = new FileDataSource(file);
this.setDataHandler(new DataHandler(fds));
this.setFileName(fds.getName());
|
public void | attachFile(java.lang.String file)Use the specified file to provide the data for this part.
The simple file name is used as the file name for this
part and the data in the file is used as the data for this
part. The encoding will be chosen appropriately for the
file data.
File f = new File(file);
attachFile(f);
|
public java.util.Enumeration | getAllHeaderLines()Get all header lines as an Enumeration of Strings. A Header
line is a raw RFC 822 header line, containing both the "name"
and "value" field.
return headers.getAllHeaderLines();
|
public java.util.Enumeration | getAllHeaders()Return all the headers from this Message as an Enumeration of
Header objects.
return headers.getAllHeaders();
|
public java.lang.Object | getContent()Return the content as a Java object. The type of the object
returned is of course dependent on the content itself. For
example, the native format of a text/plain content is usually
a String object. The native format for a "multipart"
content is always a Multipart subclass. For content types that are
unknown to the DataHandler system, an input stream is returned
as the content.
This implementation obtains the content from the DataHandler.
That is, it invokes getDataHandler().getContent();
If the content is a Multipart or Message object and was created by
parsing a stream, the object is cached and returned in subsequent
calls so that modifications to the content will not be lost.
if (cachedContent != null)
return cachedContent;
Object c;
try {
c = getDataHandler().getContent();
} catch (FolderClosedIOException fex) {
throw new FolderClosedException(fex.getFolder(), fex.getMessage());
} catch (MessageRemovedIOException mex) {
throw new MessageRemovedException(mex.getMessage());
}
if (cacheMultipart &&
(c instanceof Multipart || c instanceof Message) &&
(content != null || contentStream != null)) {
cachedContent = c;
}
return c;
|
public java.lang.String | getContentID()Returns the value of the "Content-ID" header field. Returns
null if the field is unavailable or its value is
absent.
This implementation uses getHeader(name)
to obtain the requisite header field.
return getHeader("Content-Id", null);
|
public java.lang.String[] | getContentLanguage()Get the languages specified in the Content-Language header
of this MimePart. The Content-Language header is defined by
RFC 1766. Returns null if this header is not
available or its value is absent.
This implementation uses getHeader(name)
to obtain the requisite header field.
return getContentLanguage(this);
|
static java.lang.String[] | getContentLanguage(javax.mail.internet.MimePart part)
String s = part.getHeader("Content-Language", null);
if (s == null)
return null;
// Tokenize the header to obtain the Language-tags (skip comments)
HeaderTokenizer h = new HeaderTokenizer(s, HeaderTokenizer.MIME);
Vector v = new Vector();
HeaderTokenizer.Token tk;
int tkType;
while (true) {
tk = h.next(); // get a language-tag
tkType = tk.getType();
if (tkType == HeaderTokenizer.Token.EOF)
break; // done
else if (tkType == HeaderTokenizer.Token.ATOM)
v.addElement(tk.getValue());
else // invalid token, skip it.
continue;
}
if (v.size() == 0)
return null;
String[] language = new String[v.size()];
v.copyInto(language);
return language;
|
public java.lang.String | getContentMD5()Return the value of the "Content-MD5" header field. Returns
null if this field is unavailable or its value
is absent.
This implementation uses getHeader(name)
to obtain the requisite header field.
return getHeader("Content-MD5", null);
|
protected java.io.InputStream | getContentStream()Produce the raw bytes of the content. This method is used
when creating a DataHandler object for the content. Subclasses
that can provide a separate input stream for just the Part
content might want to override this method.
if (contentStream != null)
return ((SharedInputStream)contentStream).newStream(0, -1);
if (content != null)
return new ByteArrayInputStream(content);
throw new MessagingException("No content");
|
public java.lang.String | getContentType()Returns the value of the RFC 822 "Content-Type" header field.
This represents the content type of the content of this
body part. This value must not be null. If this field is
unavailable, "text/plain" should be returned.
This implementation uses getHeader(name)
to obtain the requisite header field.
String s = getHeader("Content-Type", null);
if (s == null)
s = "text/plain";
return s;
|
public javax.activation.DataHandler | getDataHandler()Return a DataHandler for this body part's content.
The implementation provided here works just like the
the implementation in MimeMessage.
if (dh == null)
dh = new MimePartDataHandler(new MimePartDataSource(this));
return dh;
|
public java.lang.String | getDescription()Returns the "Content-Description" header field of this body part.
This typically associates some descriptive information with
this part. Returns null if this field is unavailable or its
value is absent.
If the Content-Description field is encoded as per RFC 2047,
it is decoded and converted into Unicode. If the decoding or
conversion fails, the raw data is returned as is.
This implementation uses getHeader(name)
to obtain the requisite header field.
return getDescription(this);
|
static java.lang.String | getDescription(javax.mail.internet.MimePart part)
String rawvalue = part.getHeader("Content-Description", null);
if (rawvalue == null)
return null;
try {
return MimeUtility.decodeText(MimeUtility.unfold(rawvalue));
} catch (UnsupportedEncodingException ex) {
return rawvalue;
}
|
static java.lang.String | getDisposition(javax.mail.internet.MimePart part)
String s = part.getHeader("Content-Disposition", null);
if (s == null)
return null;
ContentDisposition cd = new ContentDisposition(s);
return cd.getDisposition();
|
public java.lang.String | getDisposition()Returns the value of the "Content-Disposition" header field.
This represents the disposition of this part. The disposition
describes how the part should be presented to the user.
If the Content-Disposition field is unavailable,
null is returned.
This implementation uses getHeader(name)
to obtain the requisite header field.
return getDisposition(this);
|
public java.lang.String | getEncoding()Returns the content transfer encoding from the
"Content-Transfer-Encoding" header
field. Returns null if the header is unavailable
or its value is absent.
This implementation uses getHeader(name)
to obtain the requisite header field.
return getEncoding(this);
|
static java.lang.String | getEncoding(javax.mail.internet.MimePart part)
String s = part.getHeader("Content-Transfer-Encoding", null);
if (s == null)
return null;
s = s.trim(); // get rid of trailing spaces
// quick check for known values to avoid unnecessary use
// of tokenizer.
if (s.equalsIgnoreCase("7bit") || s.equalsIgnoreCase("8bit") ||
s.equalsIgnoreCase("quoted-printable") ||
s.equalsIgnoreCase("binary") ||
s.equalsIgnoreCase("base64"))
return s;
// Tokenize the header to obtain the encoding (skip comments)
HeaderTokenizer h = new HeaderTokenizer(s, HeaderTokenizer.MIME);
HeaderTokenizer.Token tk;
int tkType;
for (;;) {
tk = h.next(); // get a token
tkType = tk.getType();
if (tkType == HeaderTokenizer.Token.EOF)
break; // done
else if (tkType == HeaderTokenizer.Token.ATOM)
return tk.getValue();
else // invalid token, skip it.
continue;
}
return s;
|
public java.lang.String | getFileName()Get the filename associated with this body part.
Returns the value of the "filename" parameter from the
"Content-Disposition" header field of this body part. If its
not available, returns the value of the "name" parameter from
the "Content-Type" header field of this body part.
Returns null if both are absent.
If the mail.mime.encodefilename System property
is set to true, the {@link MimeUtility#decodeText
MimeUtility.decodeText} method will be used to decode the
filename. While such encoding is not supported by the MIME
spec, many mailers use this technique to support non-ASCII
characters in filenames. The default value of this property
is false.
return getFileName(this);
|
static java.lang.String | getFileName(javax.mail.internet.MimePart part)
String filename = null;
String s = part.getHeader("Content-Disposition", null);
if (s != null) {
// Parse the header ..
ContentDisposition cd = new ContentDisposition(s);
filename = cd.getParameter("filename");
}
if (filename == null) {
// Still no filename ? Try the "name" ContentType parameter
s = part.getHeader("Content-Type", null);
if (s != null) {
try {
ContentType ct = new ContentType(s);
filename = ct.getParameter("name");
} catch (ParseException pex) { } // ignore it
}
}
if (decodeFileName && filename != null) {
try {
filename = MimeUtility.decodeText(filename);
} catch (UnsupportedEncodingException ex) {
throw new MessagingException("Can't decode filename", ex);
}
}
return filename;
|
public java.lang.String[] | getHeader(java.lang.String name)Get all the headers for this header_name. Note that certain
headers may be encoded as per RFC 2047 if they contain
non US-ASCII characters and these should be decoded.
return headers.getHeader(name);
|
public java.lang.String | getHeader(java.lang.String name, java.lang.String delimiter)Get all the headers for this header name, returned as a single
String, with headers separated by the delimiter. If the
delimiter is null , only the first header is
returned.
return headers.getHeader(name, delimiter);
|
public java.io.InputStream | getInputStream()Return a decoded input stream for this body part's "content".
This implementation obtains the input stream from the DataHandler.
That is, it invokes getDataHandler().getInputStream();
return getDataHandler().getInputStream();
|
public int | getLineCount()Return the number of lines for the content of this Part.
Return -1 if this number cannot be determined.
Note that this number may not be an exact measure of the
content length and may or may not account for any transfer
encoding of the content.
This implementation returns -1.
return -1;
|
public java.util.Enumeration | getMatchingHeaderLines(java.lang.String[] names)Get matching header lines as an Enumeration of Strings.
A Header line is a raw RFC 822 header line, containing both
the "name" and "value" field.
return headers.getMatchingHeaderLines(names);
|
public java.util.Enumeration | getMatchingHeaders(java.lang.String[] names)Return matching headers from this Message as an Enumeration of
Header objects.
return headers.getMatchingHeaders(names);
|
public java.util.Enumeration | getNonMatchingHeaderLines(java.lang.String[] names)Get non-matching header lines as an Enumeration of Strings.
A Header line is a raw RFC 822 header line, containing both
the "name" and "value" field.
return headers.getNonMatchingHeaderLines(names);
|
public java.util.Enumeration | getNonMatchingHeaders(java.lang.String[] names)Return non-matching headers from this Message as an
Enumeration of Header objects.
return headers.getNonMatchingHeaders(names);
|
public java.io.InputStream | getRawInputStream()Return an InputStream to the raw data with any Content-Transfer-Encoding
intact. This method is useful if the "Content-Transfer-Encoding"
header is incorrect or corrupt, which would prevent the
getInputStream method or getContent method
from returning the correct data. In such a case the application may
use this method and attempt to decode the raw data itself.
This implementation simply calls the getContentStream
method.
return getContentStream();
|
public int | getSize()Return the size of the content of this body part in bytes.
Return -1 if the size cannot be determined.
Note that this number may not be an exact measure of the
content size and may or may not account for any transfer
encoding of the content.
This implementation returns the size of the content
array (if not null), or, if contentStream is not
null, and the available method returns a positive
number, it returns that number as the size. Otherwise, it returns
-1.
if (content != null)
return content.length;
if (contentStream != null) {
try {
int size = contentStream.available();
// only believe the size if it's greate than zero, since zero
// is the default returned by the InputStream class itself
if (size > 0)
return size;
} catch (IOException ex) {
// ignore it
}
}
return -1;
|
static void | invalidateContentHeaders(javax.mail.internet.MimePart part)
part.removeHeader("Content-Type");
part.removeHeader("Content-Transfer-Encoding");
|
static boolean | isMimeType(javax.mail.internet.MimePart part, java.lang.String mimeType)
// XXX - lots of room for optimization here!
try {
ContentType ct = new ContentType(part.getContentType());
return ct.match(mimeType);
} catch (ParseException ex) {
return part.getContentType().equalsIgnoreCase(mimeType);
}
|
public boolean | isMimeType(java.lang.String mimeType)Is this Part of the specified MIME type? This method
compares only the primaryType and
subType .
The parameters of the content types are ignored.
For example, this method will return true when
comparing a Part of content type "text/plain"
with "text/plain; charset=foobar".
If the subType of mimeType is the
special character '*', then the subtype is ignored during the
comparison.
return isMimeType(this, mimeType);
|
public void | removeHeader(java.lang.String name)Remove all headers with this name.
headers.removeHeader(name);
|
public void | saveFile(java.io.File file)Save the contents of this part in the specified file. The content
is decoded and saved, without any of the MIME headers.
OutputStream out = null;
InputStream in = null;
try {
out = new BufferedOutputStream(new FileOutputStream(file));
in = this.getInputStream();
byte[] buf = new byte[8192];
int len;
while ((len = in.read(buf)) > 0)
out.write(buf, 0, len);
} finally {
// close streams, but don't mask original exception, if any
try {
if (in != null)
in.close();
} catch (IOException ex) { }
try {
if (out != null)
out.close();
} catch (IOException ex) { }
}
|
public void | saveFile(java.lang.String file)Save the contents of this part in the specified file. The content
is decoded and saved, without any of the MIME headers.
File f = new File(file);
saveFile(f);
|
public void | setContent(java.lang.Object o, java.lang.String type)A convenience method for setting this body part's content.
The content is wrapped in a DataHandler object. Note that a
DataContentHandler class for the specified type should be
available to the JavaMail implementation for this to work right.
That is, to do setContent(foobar, "application/x-foobar") ,
a DataContentHandler for "application/x-foobar" should be installed.
Refer to the Java Activation Framework for more information.
if (o instanceof Multipart) {
setContent((Multipart)o);
} else {
setDataHandler(new DataHandler(o, type));
}
|
public void | setContent(javax.mail.Multipart mp)This method sets the body part's content to a Multipart object.
setDataHandler(new DataHandler(mp, mp.getContentType()));
mp.setParent(this);
|
public void | setContentID(java.lang.String cid)Set the "Content-ID" header field of this body part.
If the cid parameter is null, any existing
"Content-ID" is removed.
if (cid == null)
removeHeader("Content-ID");
else
setHeader("Content-ID", cid);
|
public void | setContentLanguage(java.lang.String[] languages)Set the Content-Language header of this MimePart. The
Content-Language header is defined by RFC 1766.
setContentLanguage(this, languages);
|
static void | setContentLanguage(javax.mail.internet.MimePart part, java.lang.String[] languages)
StringBuffer sb = new StringBuffer(languages[0]);
for (int i = 1; i < languages.length; i++)
sb.append(',").append(languages[i]);
part.setHeader("Content-Language", sb.toString());
|
public void | setContentMD5(java.lang.String md5)Set the "Content-MD5" header field of this body part.
setHeader("Content-MD5", md5);
|
public void | setDataHandler(javax.activation.DataHandler dh)This method provides the mechanism to set this body part's content.
The given DataHandler object should wrap the actual content.
this.dh = dh;
cachedContent = null;
MimeBodyPart.invalidateContentHeaders(this);
|
public void | setDescription(java.lang.String description)Set the "Content-Description" header field for this body part.
If the description parameter is null , then any
existing "Content-Description" fields are removed.
If the description contains non US-ASCII characters, it will
be encoded using the platform's default charset. If the
description contains only US-ASCII characters, no encoding
is done and it is used as is.
Note that if the charset encoding process fails, a
MessagingException is thrown, and an UnsupportedEncodingException
is included in the chain of nested exceptions within the
MessagingException.
setDescription(description, null);
|
public void | setDescription(java.lang.String description, java.lang.String charset)Set the "Content-Description" header field for this body part.
If the description parameter is null , then any
existing "Content-Description" fields are removed.
If the description contains non US-ASCII characters, it will
be encoded using the specified charset. If the description
contains only US-ASCII characters, no encoding is done and
it is used as is.
Note that if the charset encoding process fails, a
MessagingException is thrown, and an UnsupportedEncodingException
is included in the chain of nested exceptions within the
MessagingException.
setDescription(this, description, charset);
|
static void | setDescription(javax.mail.internet.MimePart part, java.lang.String description, java.lang.String charset)
if (description == null) {
part.removeHeader("Content-Description");
return;
}
try {
part.setHeader("Content-Description", MimeUtility.fold(21,
MimeUtility.encodeText(description, charset, null)));
} catch (UnsupportedEncodingException uex) {
throw new MessagingException("Encoding error", uex);
}
|
static void | setDisposition(javax.mail.internet.MimePart part, java.lang.String disposition)
if (disposition == null)
part.removeHeader("Content-Disposition");
else {
String s = part.getHeader("Content-Disposition", null);
if (s != null) {
/* A Content-Disposition header already exists ..
*
* Override disposition, but attempt to retain
* existing disposition parameters
*/
ContentDisposition cd = new ContentDisposition(s);
cd.setDisposition(disposition);
disposition = cd.toString();
}
part.setHeader("Content-Disposition", disposition);
}
|
public void | setDisposition(java.lang.String disposition)Set the "Content-Disposition" header field of this body part.
If the disposition is null, any existing "Content-Disposition"
header field is removed.
setDisposition(this, disposition);
|
static void | setEncoding(javax.mail.internet.MimePart part, java.lang.String encoding)
part.setHeader("Content-Transfer-Encoding", encoding);
|
public void | setFileName(java.lang.String filename)Set the filename associated with this body part, if possible.
Sets the "filename" parameter of the "Content-Disposition"
header field of this body part. For compatibility with older
mailers, the "name" parameter of the "Content-Type" header is
also set.
If the mail.mime.encodefilename System property
is set to true, the {@link MimeUtility#encodeText
MimeUtility.encodeText} method will be used to encode the
filename. While such encoding is not supported by the MIME
spec, many mailers use this technique to support non-ASCII
characters in filenames. The default value of this property
is false.
setFileName(this, filename);
|
static void | setFileName(javax.mail.internet.MimePart part, java.lang.String name)
if (encodeFileName && name != null) {
try {
name = MimeUtility.encodeText(name);
} catch (UnsupportedEncodingException ex) {
throw new MessagingException("Can't encode filename", ex);
}
}
// Set the Content-Disposition "filename" parameter
String s = part.getHeader("Content-Disposition", null);
ContentDisposition cd =
new ContentDisposition(s == null ? Part.ATTACHMENT : s);
cd.setParameter("filename", name);
part.setHeader("Content-Disposition", cd.toString());
/*
* Also attempt to set the Content-Type "name" parameter,
* to satisfy ancient MUAs. XXX - This is not RFC compliant.
*/
if (setContentTypeFileName) {
s = part.getHeader("Content-Type", null);
if (s != null) {
try {
ContentType cType = new ContentType(s);
cType.setParameter("name", name);
part.setHeader("Content-Type", cType.toString());
} catch (ParseException pex) { } // ignore it
}
}
|
public void | setHeader(java.lang.String name, java.lang.String value)Set the value for this header_name. Replaces all existing
header values with this new value. Note that RFC 822 headers
must contain only US-ASCII characters, so a header that
contains non US-ASCII characters must be encoded as per the
rules of RFC 2047.
headers.setHeader(name, value);
|
public void | setText(java.lang.String text)Convenience method that sets the given String as this
part's content, with a MIME type of "text/plain". If the
string contains non US-ASCII characters, it will be encoded
using the platform's default charset. The charset is also
used to set the "charset" parameter.
Note that there may be a performance penalty if
text is large, since this method may have
to scan all the characters to determine what charset to
use.
If the charset is already known, use the
setText method that takes the charset parameter.
setText(text, null);
|
public void | setText(java.lang.String text, java.lang.String charset)Convenience method that sets the given String as this part's
content, with a MIME type of "text/plain" and the specified
charset. The given Unicode string will be charset-encoded
using the specified charset. The charset is also used to set
the "charset" parameter.
setText(this, text, charset, "plain");
|
public void | setText(java.lang.String text, java.lang.String charset, java.lang.String subtype)Convenience method that sets the given String as this part's
content, with a primary MIME type of "text" and the specified
MIME subtype. The given Unicode string will be charset-encoded
using the specified charset. The charset is also used to set
the "charset" parameter.
setText(this, text, charset, subtype);
|
static void | setText(javax.mail.internet.MimePart part, java.lang.String text, java.lang.String charset, java.lang.String subtype)
if (charset == null) {
if (MimeUtility.checkAscii(text) != MimeUtility.ALL_ASCII)
charset = MimeUtility.getDefaultMIMECharset();
else
charset = "us-ascii";
}
// XXX - should at least ensure that subtype is an atom
part.setContent(text, "text/" + subtype + "; charset=" +
MimeUtility.quote(charset, HeaderTokenizer.MIME));
|
protected void | updateHeaders()Examine the content of this body part and update the appropriate
MIME headers. Typical headers that get set here are
Content-Type and Content-Transfer-Encoding .
Headers might need to be updated in two cases:
- A message being crafted by a mail application will certainly
need to activate this method at some point to fill up its internal
headers.
- A message read in from a Store will have obtained
all its headers from the store, and so doesn't need this.
However, if this message is editable and if any edits have
been made to either the content or message structure, we might
need to resync our headers.
In both cases this method is typically called by the
Message.saveChanges method.
updateHeaders(this);
/*
* If we've cached a Multipart or Message object then
* we're now committed to using this instance of the
* object and we discard any stream data used to create
* this object.
*/
if (cachedContent != null) {
dh = new DataHandler(cachedContent, getContentType());
cachedContent = null;
content = null;
if (contentStream != null) {
try {
contentStream.close();
} catch (IOException ioex) { } // nothing to do
}
contentStream = null;
}
|
static void | updateHeaders(javax.mail.internet.MimePart part)
DataHandler dh = part.getDataHandler();
if (dh == null) // Huh ?
return;
if (dh instanceof MimePartDataHandler)
return; // can't update it
try {
String type = dh.getContentType();
boolean composite = false;
boolean needCTHeader = part.getHeader("Content-Type") == null;
ContentType cType = new ContentType(type);
if (cType.match("multipart/*")) {
// If multipart, recurse
composite = true;
Object o;
if (part instanceof MimeBodyPart) {
MimeBodyPart mbp = (MimeBodyPart)part;
o = mbp.cachedContent != null ?
mbp.cachedContent : dh.getContent();
} else if (part instanceof MimeMessage) {
MimeMessage msg = (MimeMessage)part;
o = msg.cachedContent != null ?
msg.cachedContent : dh.getContent();
} else
o = dh.getContent();
if (o instanceof MimeMultipart)
((MimeMultipart)o).updateHeaders();
else
throw new MessagingException("MIME part of type \"" +
type + "\" contains object of type " +
o.getClass().getName() + " instead of MimeMultipart");
} else if (cType.match("message/rfc822")) {
composite = true;
// XXX - call MimeMessage.updateHeaders()?
}
// Content-Transfer-Encoding, but only if we don't
// already have one
if (!composite) { // not allowed on composite parts
if (part.getHeader("Content-Transfer-Encoding") == null)
setEncoding(part, MimeUtility.getEncoding(dh));
if (needCTHeader && setDefaultTextCharset &&
cType.match("text/*") &&
cType.getParameter("charset") == null) {
/*
* Set a default charset for text parts.
* We really should examine the data to determine
* whether or not it's all ASCII, but that's too
* expensive so we make an assumption: If we
* chose 7bit encoding for this data, it's probably
* ASCII. (MimeUtility.getEncoding will choose
* 7bit only in this case, but someone might've
* set the Content-Transfer-Encoding header manually.)
*/
String charset;
String enc = part.getEncoding();
if (enc != null && enc.equalsIgnoreCase("7bit"))
charset = "us-ascii";
else
charset = MimeUtility.getDefaultMIMECharset();
cType.setParameter("charset", charset);
type = cType.toString();
}
}
// Now, let's update our own headers ...
// Content-type, but only if we don't already have one
if (needCTHeader) {
/*
* Pull out "filename" from Content-Disposition, and
* use that to set the "name" parameter. This is to
* satisfy older MUAs (DtMail, Roam and probably
* a bunch of others).
*/
String s = part.getHeader("Content-Disposition", null);
if (s != null) {
// Parse the header ..
ContentDisposition cd = new ContentDisposition(s);
String filename = cd.getParameter("filename");
if (filename != null) {
cType.setParameter("name", filename);
type = cType.toString();
}
}
part.setHeader("Content-Type", type);
}
} catch (IOException ex) {
throw new MessagingException("IOException updating headers", ex);
}
|
public void | writeTo(java.io.OutputStream os)Output the body part as an RFC 822 format stream.
writeTo(this, os, null);
|
static void | writeTo(javax.mail.internet.MimePart part, java.io.OutputStream os, java.lang.String[] ignoreList)
// see if we already have a LOS
LineOutputStream los = null;
if (os instanceof LineOutputStream) {
los = (LineOutputStream) os;
} else {
los = new LineOutputStream(os);
}
// First, write out the header
Enumeration hdrLines = part.getNonMatchingHeaderLines(ignoreList);
while (hdrLines.hasMoreElements())
los.writeln((String)hdrLines.nextElement());
// The CRLF separator between header and content
los.writeln();
// Finally, the content. Encode if required.
// XXX: May need to account for ESMTP ?
os = MimeUtility.encode(os, part.getEncoding());
part.getDataHandler().writeTo(os);
os.flush(); // Needed to complete encoding
|