Esempio n. 1
0
 @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;
 }
Esempio n. 2
0
 @Override
 public Address[] getReplyTo() {
   if (mReplyTo == null) {
     mReplyTo = Address.parse(MimeUtility.unfold(getFirstHeader("Reply-to")));
   }
   return mReplyTo;
 }
Esempio n. 3
0
 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);
   }
 }
Esempio n. 4
0
 @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);
   }
 }
Esempio n. 5
0
 /**
  * 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.");
   }
 }
Esempio n. 6
0
  @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;
  }
Esempio n. 7
0
 /** Returns the unfolded, decoded value of the Subject header. */
 @Override
 public String getSubject() {
   return MimeUtility.unfoldAndDecode(getFirstHeader("Subject"), this);
 }
Esempio n. 8
0
 public String getMimeType() throws MessagingException {
   return MimeUtility.getHeaderParameter(getContentType(), null);
 }