本文整理匯總了Java中org.apache.james.mime4j.message.HeaderImpl類的典型用法代碼示例。如果您正苦於以下問題:Java HeaderImpl類的具體用法?Java HeaderImpl怎麽用?Java HeaderImpl使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
HeaderImpl類屬於org.apache.james.mime4j.message包,在下文中一共展示了HeaderImpl類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: testAppend
import org.apache.james.mime4j.message.HeaderImpl; //導入依賴的package包/類
@Test
public void testAppend() throws Exception {
Header header = new HeaderImpl();
header.addField(DefaultFieldParser.parse("Subject: This is the subject"));
header.addField(DefaultFieldParser.parse("To: [email protected]"));
header.addField(DefaultFieldParser.parse("From: [email protected]"));
header.addField(DefaultFieldParser.parse("Date: 10-MAY-1994 00:00:00 -0000 (UTC)"));
header.addField(DefaultFieldParser.parse("Message-ID: 12345"));
Envelope envelope = new Envelope.Builder().setDate(ZonedDateTime.of(1994, 5, 10, 0, 0, 0, 0, ZoneId.of("UTC")));
Body body = BasicBodyFactory.INSTANCE.textBody("This is a test");
Message message = new MessageImpl();
message.setBody(body);
message.setHeader(header);
ImapMessage imapMessage = new ImapMessage.Builder()
.setFlags(ImmutableSet.of(StandardMessageFlag.SEEN, StandardMessageFlag.RECENT))
.setEnvelope(envelope)
.setBody(message);
FetchResponse preAppendFetchAll = client.fetch(1, Optional.empty(), FetchDataItemType.UID, FetchDataItemType.FLAGS, FetchDataItemType.ENVELOPE, new BodyPeekFetchDataItem()).get();
assertThat(preAppendFetchAll.getMessages().size()).isEqualTo(1);
TaggedResponse appendResponse = client.append(DEFAULT_FOLDER, imapMessage.getFlags(), imapMessage.getEnvelope().getDate(), imapMessage).get();
assertThat(appendResponse.getCode()).isEqualTo(ResponseCode.OK);
long uid = Long.parseLong(appendResponse.getMessage().substring(25, 26));
FetchResponse postAppendFetchAll = client.fetch(1, Optional.empty(), FetchDataItemType.UID, FetchDataItemType.ENVELOPE, new BodyPeekFetchDataItem()).get();
assertThat(postAppendFetchAll.getMessages().size()).isEqualTo(2);
FetchResponse postAppendFetchUid = client.uidfetch(uid, Optional.of(uid), FetchDataItemType.UID, FetchDataItemType.ENVELOPE, new BodyPeekFetchDataItem()).get();
assertThat(postAppendFetchUid.getMessages().size()).isEqualTo(1);
assertThat(postAppendFetchUid.getMessages().iterator().next().getBody().getSubject()).isEqualToIgnoringCase("This is the subject");
assertThat(postAppendFetchUid.getMessages().iterator().next().getEnvelope().getMessageId()).isEqualToIgnoringCase("12345");
}
示例2: Email
import org.apache.james.mime4j.message.HeaderImpl; //導入依賴的package包/類
public Email(){
this.header = new HeaderImpl();
this.attachments = new ArrayList<Attachment>();
this.attachmentReplacedInHtmlBody = false;
this.multipartStack = new Stack<MultipartType>();
this.emailMessageStack = new Stack<EmailMessageType>();
this.decodedEmailSize = 0;
this.emailSize = 0;
}
示例3: startHeader
import org.apache.james.mime4j.message.HeaderImpl; //導入依賴的package包/類
/**
* @see org.apache.james.mime4j.parser.ContentHandler#startHeader()
*/
public void startHeader() throws MimeException {
stack.push(new HeaderImpl());
}