當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。