本文整理汇总了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());
}