当前位置: 首页>>代码示例>>Java>>正文


Java HeaderImpl类代码示例

本文整理汇总了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");
}
 
开发者ID:HubSpot,项目名称:NioImapClient,代码行数:38,代码来源:ImapClientTest.java

示例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;
}
 
开发者ID:ram-sharma-6453,项目名称:email-mime-parser,代码行数:10,代码来源:Email.java

示例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());
}
 
开发者ID:QSFT,项目名称:MimeUI,代码行数:7,代码来源:MimeUIEntityBuilder.java


注:本文中的org.apache.james.mime4j.message.HeaderImpl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。