public InputStream getBodyInputStream() { try { return ((SingleBody) message.getBody()).getInputStream(); } catch (IOException e) { return null; } }
/** * @see org.apache.james.mime4j.parser.AbstractContentHandler#field(Field) */ @Override public final void field(Field field) throws MimeException { ParsedField parsedField; if (field instanceof ParsedField) { parsedField = (ParsedField) field; } else { parsedField = fieldParser.parse(field, monitor); } currHeader.addField(parsedField); }
/** * Sets <i>To</i> header field of this message to the specified * address. * * @param to * address to set or <code>null</code> to remove the header * field. */ public Builder setTo(String to) throws ParseException { return setAddressList(FieldName.TO, to); }
private Message generateMessageContent() throws IOException { return Message.Builder.of() .setSubject("toto") .setBody("content", StandardCharsets.UTF_8) .build(); }
ParsedField parsedField = LenientFieldParser.getParser().parse( field, DecodeMonitor.SILENT); if (fieldname.equalsIgnoreCase("From")) { MailboxListField fromField = (MailboxListField) parsedField; MailboxList mailboxList = fromField.getMailboxList(); if (fromField.isValidField() && mailboxList != null) { for (Address address : mailboxList) { String from = getDisplayString(address); ((UnstructuredField) parsedField).getValue()); metadata.set(TikaCoreProperties.SUBJECT, ((UnstructuredField) parsedField).getValue()); } else if (fieldname.equalsIgnoreCase("To")) { processAddressList(parsedField, "To:", Metadata.MESSAGE_TO); processAddressList(parsedField, "Bcc:", Metadata.MESSAGE_BCC); } else if (fieldname.equalsIgnoreCase("Content-Type")) { final MediaType contentType = MediaType.parse(parsedField.getBody()); metadata.set(Message.MULTIPART_BOUNDARY, contentType.getParameters().get("boundary")); } else { metadata.add(Metadata.MESSAGE_RAW_HEADER_PREFIX + parsedField.getName(), field.getBody()); Date date = dateField.getDate(); if (date == null) { date = tryOtherDateFormats(field.getBody()); metadata.add(Metadata.MESSAGE_RAW_HEADER_PREFIX+parsedField.getName(),
/** * Sets <i>From</i> header field of this message to the specified * mailbox address. * * @param from * address to set or <code>null</code> to remove the header * field. */ public Builder setFrom(String from) throws ParseException { return setMailboxList(FieldName.FROM, from); }
/** * Sets <i>Sender</i> header field of this message to the specified * mailbox address. * * @param sender * address to set or <code>null</code> to remove the header * field. */ public Builder setSender(String sender) throws ParseException { return setMailbox(FieldName.SENDER, sender); }
/** * Returns the value of the <i>Cc</i> header field of this message as * <code>AddressList</code> object or <code>null</code> if it is not * present. * * @return value of the cc field of this message. */ public AddressList getCc() { return getAddressList(FieldName.CC); }
/** * Sets the list of body parts. * * @param bodyParts * the new list of <code>Entity</code> objects. */ public void setBodyParts(List<Entity> bodyParts) { this.bodyParts = bodyParts; for (Entity bodyPart : bodyParts) { bodyPart.setParent(parent); } }
/** * Returns the value of the <i>Sender</i> header field of this message as * <code>Mailbox</code> object or <code>null</code> if it is not * present. * * @return the sender of this message. */ public Mailbox getSender() { return getMailbox(FieldName.SENDER); }
/** * Returns the value of the <i>From</i> header field of this message as * <code>MailboxList</code> object or <code>null</code> if it is not * present. * * @return value of the from field of this message. */ public MailboxList getFrom() { return getMailboxList(FieldName.FROM); }
/** * Sets <i>To</i> header field of this message to the specified * addresses. * * @param to * addresses to set or <code>null</code> or no arguments to * remove the header field. */ public Builder setTo(Address... to) { return setAddressList(FieldName.TO, to); }
/** * Sets <i>From</i> header field of this message to the specified * mailbox addresses. * * @param from * addresses to set or <code>null</code> or no arguments to * remove the header field. */ public Builder setFrom(Mailbox... from) { return setMailboxList(FieldName.FROM, from); }
/** * Sets <i>Sender</i> header field of this message to the specified * mailbox address. * * @param sender * address to set or <code>null</code> to remove the header * field. */ public Builder setSender(Mailbox sender) { return setMailbox(FieldName.SENDER, sender); }
/** * Returns the value of the <i>Bcc</i> header field of this message as * <code>AddressList</code> object or <code>null</code> if it is not * present. * * @return value of the bcc field of this message. */ public AddressList getBcc() { return getAddressList(FieldName.BCC); }
/** * Sets <i>Reply-To</i> header field of this message to the specified * addresses. * * @param replyTo * addresses to set or <code>null</code> or an empty collection * to remove the header field. */ public Builder setReplyTo(Collection<? extends Address> replyTo) { return setAddressList(FieldName.REPLY_TO, replyTo); }
/** * Sets <i>From</i> header field of this message to the specified * mailbox addresses. * * @param from * addresses to set or <code>null</code> or no arguments to * remove the header field. */ public Builder setFrom(String... from) throws ParseException { return setMailboxList(FieldName.FROM, from); }
/** * Sets <i>Cc</i> header field of this message to the specified * addresses. * * @param cc * addresses to set or <code>null</code> or no arguments to * remove the header field. */ public Builder setCc(Address... cc) { return setAddressList(FieldName.CC, cc); }
/** * Sets <i>From</i> header field of this message to the specified * mailbox addresses. * * @param from * addresses to set or <code>null</code> or an empty collection * to remove the header field. */ public Builder setFrom(Collection<Mailbox> from) { return setMailboxList(FieldName.FROM, from); }
/** * Sets <i>Bcc</i> header field of this message to the specified * addresses. * * @param bcc * addresses to set or <code>null</code> or no arguments to * remove the header field. */ public Builder setBcc(Address... bcc) { return setAddressList(FieldName.BCC, bcc); }