@Override public Address[] getFrom() { if (mFrom == null) { String list = MimeUtility.unfold(getFirstHeader("From")); if (list == null || list.length() == 0) { list = MimeUtility.unfold(getFirstHeader("Sender")); } mFrom = Address.parse(list); } return mFrom; }
@Override public Address[] getReplyTo() { if (mReplyTo == null) { mReplyTo = Address.parse(MimeUtility.unfold(getFirstHeader("Reply-to"))); } return mReplyTo; }
public void body(BodyDescriptor bd, InputStream in) throws IOException { expect(Part.class); Body body = MimeUtility.decodeBody(in, bd.getTransferEncoding()); try { ((Part) stack.peek()).setBody(body); } catch (MessagingException me) { throw new Error(me); } }
@Override public void setCharset(String charset) throws MessagingException { if (mBody instanceof Multipart) { ((Multipart) mBody).setCharset(charset); } else if (mBody instanceof TextBody) { MimeUtility.setCharset(charset, this); ((TextBody) mBody).setCharset(charset); } }
/** * Returns a list of the given recipient type from this message. If no addresses are found the * method returns an empty array. */ @Override public Address[] getRecipients(RecipientType type) throws MessagingException { if (type == RecipientType.TO) { if (mTo == null) { mTo = Address.parse(MimeUtility.unfold(getFirstHeader("To"))); } return mTo; } else if (type == RecipientType.CC) { if (mCc == null) { mCc = Address.parse(MimeUtility.unfold(getFirstHeader("CC"))); } return mCc; } else if (type == RecipientType.BCC) { if (mBcc == null) { mBcc = Address.parse(MimeUtility.unfold(getFirstHeader("BCC"))); } return mBcc; } else { throw new MessagingException("Unrecognized recipient type."); } }
@Override public Date getSentDate() { if (mSentDate == null) { try { DateTimeField field = (DateTimeField) DefaultFieldParser.parse( "Date: " + MimeUtility.unfoldAndDecode(getFirstHeader("Date"))); mSentDate = field.getDate(); } catch (Exception e) { } } return mSentDate; }
/** Returns the unfolded, decoded value of the Subject header. */ @Override public String getSubject() { return MimeUtility.unfoldAndDecode(getFirstHeader("Subject"), this); }
public String getMimeType() throws MessagingException { return MimeUtility.getHeaderParameter(getContentType(), null); }