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


Java MailDateFormat类代码示例

本文整理汇总了Java中javax.mail.internet.MailDateFormat的典型用法代码示例。如果您正苦于以下问题:Java MailDateFormat类的具体用法?Java MailDateFormat怎么用?Java MailDateFormat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MailDateFormat类属于javax.mail.internet包,在下文中一共展示了MailDateFormat类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAttributesFor

import javax.mail.internet.MailDateFormat; //导入依赖的package包/类
void setAttributesFor(MimeMessage msg) throws MessagingException {
    try {
        internalDate = msg.getSentDate();
    } catch (MessagingException me) {
        internalDate = new Date();
    }
    if (null == internalDate) {
        internalDate = new Date();
    }

    /*  
     * mrogers
     * Internal Date Format must conform to RFC 3501
     */
    internalDateString = new SimpleDateFormat("dd-MMM-yyyy hh:mm:ss Z", Locale.ENGLISH).format(internalDate);
    interalDateEnvelopeString = new MailDateFormat().format(internalDate);
    parseMimePart(msg);
    envelope = null;
    bodyStructure = null;
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:21,代码来源:SimpleMessageAttributes.java

示例2: updateHeaders

import javax.mail.internet.MailDateFormat; //导入依赖的package包/类
/**
 * Removes all headers that are not on the whitelist, and initializes some
 * basic header fields.<br/>
 * Called by {@link #saveChanges()}, see JavaMail JavaDoc.
 * @throws MessagingException
 */
@Override
public void updateHeaders() throws MessagingException {
    super.updateHeaders();
    scrubHeaders();
    removeRecipientNames();
    
    // Depending on includeSendTime, set the send time or remove the send time field
    if (includeSendTime) {
        if (getSentDate() == null) {
            // Set the "Date" field in UTC time, using the English locale.
            MailDateFormat formatter = new MailDateFormat();
            formatter.setTimeZone(TimeZone.getTimeZone("GMT"));   // always use UTC for outgoing mail
            setHeader("Date", formatter.format(new Date()));
        }
    }
    else
        removeHeader("Date");
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:25,代码来源:Email.java

示例3: assertCorrectDate

import javax.mail.internet.MailDateFormat; //导入依赖的package包/类
private void assertCorrectDate(final String mailDate, final Instant minimalRaw, final Instant maximalRaw)
        throws ParseException {
    final Instant actual = new MailDateFormat().parse(mailDate).toInstant();

    final Instant minimal = minimalRaw.atOffset(UTC).withNano(0).minusNanos(1).toInstant();
    final Instant maximal = minimalRaw.atOffset(UTC).withNano(1).plusSeconds(1).toInstant();
    assertThat(actual.isAfter(minimal))
            .overridingErrorMessage("The date of the mail should be after %s but was %s.", minimal, actual)
            .isTrue();
    assertThat(actual.isBefore(maximal))
            .overridingErrorMessage("The date of the mail should be before %s but was %s.", maximal, actual)
            .isTrue();
}
 
开发者ID:rbi,项目名称:trading4j,代码行数:14,代码来源:MailSenderIT.java

示例4: getCreateTime

import javax.mail.internet.MailDateFormat; //导入依赖的package包/类
/**
 * Returns the date and time the email was submitted by the user, or <code>null</code>
 * if the value cannot be parsed.
 */
public Date getCreateTime() {
    String dateStr = getProperty(PROPERTY_CREATE_TIME);
    Date createTime;
    try {
        createTime = new MailDateFormat().parse(dateStr);
    } catch (ParseException e) {
        log.error("Can't parse create time.", e);
        createTime = null;
    }
    return createTime;
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:16,代码来源:EmailMetadata.java

示例5: setCreateTime

import javax.mail.internet.MailDateFormat; //导入依赖的package包/类
public void setCreateTime(Date createTime) {
    setProperty(PROPERTY_CREATE_TIME, new MailDateFormat().format(createTime));
}
 
开发者ID:NoYouShutup,项目名称:CryptMeme,代码行数:4,代码来源:EmailMetadata.java

示例6: main

import javax.mail.internet.MailDateFormat; //导入依赖的package包/类
public static void main(String args[]) throws Exception {
	
	// read test configuration from test.properties in your classpath
	Properties testProps = TestUtil.readProperties();
	
	// generate string buffered test mail
	StringBuffer mimeMail = new StringBuffer();
	mimeMail.append("Date: ").append(new MailDateFormat().format(new Date())).append("\r\n");
	mimeMail.append("From: ").append(testProps.getProperty("mail.smtp.from")).append("\r\n");
	if (testProps.getProperty("mail.smtp.to") != null) {
		mimeMail.append("To: ").append(testProps.getProperty("mail.smtp.to")).append("\r\n");
	}
	if (testProps.getProperty("mail.smtp.cc") != null) {
		mimeMail.append("Cc: ").append(testProps.getProperty("mail.smtp.cc")).append("\r\n");
	}
	mimeMail.append("Subject: ").append("DKIM for JavaMail: MimeMailExample Testmessage").append("\r\n");
	mimeMail.append("\r\n");
	mimeMail.append(TestUtil.bodyText);

	// get a JavaMail Session object 
	Session session = Session.getDefaultInstance(testProps, null);

	
	
	///////// beginning of DKIM FOR JAVAMAIL stuff
	
	// get DKIMSigner object
	DKIMSigner dkimSigner = new DKIMSigner(
			testProps.getProperty("mail.smtp.dkim.signingdomain"),
			testProps.getProperty("mail.smtp.dkim.selector"),
			testProps.getProperty("mail.smtp.dkim.privatekey"));

	/* set an address or user-id of the user on behalf this message was signed;
	 * this identity is up to you, except the domain part must be the signing domain
	 * or a subdomain of the signing domain.
	 */ 
	dkimSigner.setIdentity("[email protected]"+testProps.getProperty("mail.smtp.dkim.signingdomain"));

	// construct the JavaMail message using the DKIM message type from DKIM for JavaMail
	Message msg = new SMTPDKIMMessage(session, new ByteArrayInputStream(mimeMail.toString().getBytes()), dkimSigner);

	///////// end of DKIM FOR JAVAMAIL stuff

	// send the message by JavaMail
	Transport transport = session.getTransport("smtp");
	transport.connect(testProps.getProperty("mail.smtp.host"),
			testProps.getProperty("mail.smtp.auth.user"),
			testProps.getProperty("mail.smtp.auth.password"));
	transport.sendMessage(msg, msg.getAllRecipients());
	transport.close();
}
 
开发者ID:usrflo,项目名称:DKIM-for-JavaMail,代码行数:52,代码来源:MimeMailExample.java

示例7: WriteMailToNew

import javax.mail.internet.MailDateFormat; //导入依赖的package包/类
public void WriteMailToNew(OneNote note, String usesticky, String noteBody) throws MessagingException, IOException {
  String body = null;

  // Here we add the new note to the "new" folder
  //Log.d(TAG,"Add new note");
  Properties props = new Properties();
  Session session = Session.getDefaultInstance(props, null);
  MimeMessage message = new MimeMessage(session);
  if (usesticky.equals("true")) {
    body = "BEGIN:STICKYNOTE\nCOLOR:" + this.color + "\nTEXT:" + noteBody +
           "\nPOSITION:0 0 0 0\nEND:STICKYNOTE";
    message.setText(body);
    message.setHeader("Content-Transfer-Encoding", "8bit");
    message.setHeader("Content-Type","text/x-stickynote; charset=\"utf-8\"");
  } else {
    message.setHeader("X-Uniform-Type-Identifier","com.apple.mail-note");
    UUID uuid = UUID.randomUUID();
    message.setHeader("X-Universally-Unique-Identifier", uuid.toString());
    body = noteBody;
    body = body.replaceFirst("<p dir=ltr>", "<div>");
    body = body.replaceFirst("<p dir=\"ltr\">", "<div>");
    body = body.replaceAll("<p dir=ltr>", "<div><br></div><div>");
    body = body.replaceAll("<p dir=\"ltr\">", "<div><br></div><div>");
    body = body.replaceAll("</p>", "</div>");
    body = body.replaceAll("<br>\n", "</div><div>");
    message.setText(body, "utf-8", "html");
    message.setFlag(Flags.Flag.SEEN,true);
  }
  message.setSubject(note.GetTitle());
  MailDateFormat mailDateFormat = new MailDateFormat();
  // Remove (CET) or (GMT+1) part as asked in github issue #13
  String headerDate = (mailDateFormat.format(new Date())).replaceAll("\\(.*$", "");
  message.addHeader("Date", headerDate);
  //déterminer l'uid temporaire
  String uid = Integer.toString(Math.abs(Integer.parseInt(note.GetUid())));
  File directory = new File ((ImapNotes2.getAppContext()).getFilesDir() + "/" +
          Listactivity.imapNotes2Account.GetAccountname() + "/new");
  //message.setFrom(new InternetAddress("ImapNotes2", Listactivity.imapNotes2Account.GetAccountname()));
  message.setFrom(Listactivity.imapNotes2Account.GetAccountname());
  File outfile = new File (directory, uid);
  OutputStream str = new FileOutputStream(outfile);
  message.writeTo(str);

}
 
开发者ID:nbenm,项目名称:ImapNote2,代码行数:45,代码来源:UpdateThread.java


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