javax.mail.Message.getFolder()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(6.8k)|赞(0)|评价(0)|浏览(152)

本文整理了Java中javax.mail.Message.getFolder()方法的一些代码示例,展示了Message.getFolder()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Message.getFolder()方法的具体详情如下:
包路径:javax.mail.Message
类名称:Message
方法名:getFolder

Message.getFolder介绍

[英]Get the folder from which this message was obtained. If this is a new message or nested message, this method returns null.
[中]获取获取此邮件的文件夹。如果这是新消息或嵌套消息,此方法将返回null。

代码示例

代码示例来源:origin: spring-projects/spring-integration

@Override
public void messagesAdded(MessageCountEvent event) {
  Message[] messages = event.getMessages();
  if (messages.length > 0) {
    // this will return the flow to the idle call
    messages[0].getFolder().isOpen();
  }
}

代码示例来源:origin: camunda/camunda-bpm-platform

if (message.getFolder() != this)
  throw new NoSuchElementException(
  "Message does not belong to this folder");

代码示例来源:origin: com.sun.mail/javax.mail

public synchronized long getUID(Message message) 
    throws MessagingException {
if (message.getFolder() != this)
  throw new NoSuchElementException(
  "Message does not belong to this folder");

代码示例来源:origin: google/mail-importer

@Override
public Folder getFolder() {
 return delegate.getFolder();
}

代码示例来源:origin: spring-projects/spring-integration

@Test
public void testAttachments() throws Exception {
  final ImapMailReceiver receiver = new ImapMailReceiver("imap://foo");
  Folder folder = testAttachmentsGuts(receiver);
  Message[] messages = (Message[]) receiver.receive();
  Object content = messages[0].getContent();
  assertEquals("bar", ((Multipart) content).getBodyPart(0).getContent().toString().trim());
  assertEquals("foo", ((Multipart) content).getBodyPart(1).getContent().toString().trim());
  assertSame(folder, messages[0].getFolder());
}

代码示例来源:origin: org.apache.geronimo.javamail/geronimo-javamail_1.4_provider

/**
 * Check if a Message is properly within the target
 * folder.
 *
 * @param msg    The message we're checking.
 *
 * @exception MessagingException
 */
protected void checkMessageFolder(Message msg) throws MessagingException {
  if (msg.getFolder() != this) {
    throw new NoSuchElementException("Message is not within the target Folder");
  }
}

代码示例来源:origin: org.eclipse.scout.rt/org.eclipse.scout.rt.server

/**
 * @return the messages grouped by source folder
 */
protected Map<Folder, Set<Message>> groupMessagesBySourceFolder(Message[] messages) {
 Map<Folder, Set<Message>> messagesByFolder = new HashMap<>();
 if (messages == null || messages.length == 0) {
  return messagesByFolder;
 }
 for (Message message : messages) {
  if (message.isExpunged()) {
   LOG.debug("Ignoring expunged message {}", message);
   continue;
  }
  if (message.getFolder() == null) {
   LOG.warn("Folder is empty for message {}", message);
   continue;
  }
  if (!messagesByFolder.containsKey(message.getFolder())) {
   messagesByFolder.put(message.getFolder(), new HashSet<>());
  }
  messagesByFolder.get(message.getFolder()).add(message);
 }
 return messagesByFolder;
}

代码示例来源:origin: OpenNMS/opennms

/**
 * {@inheritDoc}
 *
 * Finalizer to be sure and close with the appropriate mode
 * any open folders
 */
@Override
protected void finalize() throws Throwable {
  LOG.debug("finalize: cleaning up mail folder an store connections...");
  if (m_messages != null && !m_messages.isEmpty() && m_messages.get(0).getFolder() != null && m_messages.get(0).getFolder().isOpen()) {
    m_messages.get(0).getFolder().close(m_deleteOnClose);
  }
  
  if (m_store.isConnected()) {
    m_store.close();
  }
  LOG.debug("finalize: Mail folder and store connections closed.");
  super.finalize();
}

代码示例来源:origin: org.opennms/opennms-javamail-api

/**
 * {@inheritDoc}
 *
 * Finalizer to be sure and close with the appropriate mode
 * any open folders
 */
@Override
protected void finalize() throws Throwable {
  LOG.debug("finalize: cleaning up mail folder an store connections...");
  if (m_messages != null && !m_messages.isEmpty() && m_messages.get(0).getFolder() != null && m_messages.get(0).getFolder().isOpen()) {
    m_messages.get(0).getFolder().close(m_deleteOnClose);
  }
  
  if (m_store.isConnected()) {
    m_store.close();
  }
  LOG.debug("finalize: Mail folder and store connections closed.");
  super.finalize();
}

代码示例来源:origin: org.springframework.integration/spring-integration-mail

@Override
public void messagesAdded(MessageCountEvent event) {
  Message[] messages = event.getMessages();
  if (messages.length > 0) {
    // this will return the flow to the idle call
    messages[0].getFolder().isOpen();
  }
}

代码示例来源:origin: stackoverflow.com

public void processMailExample() {
  Store store = session.getStore(new javax.mail.URLName("imap://user:pass@mailserver..."));
  store.connect();
  Folder inputFolder = store.getFolder("INBOX");
  Folder outputFolder = store.getFolder("INBOX/Processed");

  inputFolder.open(Folder.READ_WRITE);

  Message[] messages = inputFolder.getMessages();
  for (Message message : messages) {

    // Process message here

    moveMessage(message, outputFolder);
  }
}

public void moveMessage(Message m, Folder to) throws MessagingException
{
  m.getFolder().copyMessages(new Message[] {m}, to);
  m.setFlag(Flag.DELETED, true);
  m.getFolder().expunge();
}

代码示例来源:origin: org.eclipse.scout.rt/org.eclipse.scout.rt.server

/**
 * messages are flagged as DELETED and their folder is closed in order to delete them on the server
 */
@Override
public void deleteMessagesPermanently(Message[] messages) {
 connect();
 Set<Folder> folders = new HashSet<>();
 try {
  for (Message msg : messages) {
   folders.add(msg.getFolder());
   msg.setFlag(Flag.DELETED, true);
  }
  for (Folder f : folders) {
   if (f.isOpen()) {
    f.expunge();
   }
  }
 }
 catch (MessagingException e) {
  throw new ProcessingException(e.getMessage(), e);
 }
}

代码示例来源:origin: CloudSlang/cs-actions

message.getFolder().close(true);
} catch (Throwable ignore) {
} finally {

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.javax.mail

if (message.getFolder() != this)
  throw new NoSuchElementException(
  "Message does not belong to this folder");

代码示例来源:origin: javax.mail/com.springsource.javax.mail

if (message.getFolder() != this)
  throw new NoSuchElementException(
  "Message does not belong to this folder");

代码示例来源:origin: com.sun.mail/jakarta.mail

public synchronized long getUID(Message message) 
    throws MessagingException {
if (message.getFolder() != this)
  throw new NoSuchElementException(
  "Message does not belong to this folder");

代码示例来源:origin: org.glassfish.metro/webservices-extra

public synchronized long getUID(Message message) 
    throws MessagingException {
if (message.getFolder() != this)
  throw new NoSuchElementException(
  "Message does not belong to this folder");

代码示例来源:origin: com.sun.mail/android-mail

public synchronized long getUID(Message message) 
    throws MessagingException {
if (message.getFolder() != this)
  throw new NoSuchElementException(
  "Message does not belong to this folder");

代码示例来源:origin: jboss/jboss-javaee-specs

public synchronized long getUID(Message message) 
    throws MessagingException {
if (message.getFolder() != this)
  throw new NoSuchElementException(
  "Message does not belong to this folder");

代码示例来源:origin: ujmp/universal-java-matrix-package

put("SentDate", m.getSentDate());
put("Subject", m.getSubject());
put("Folder", m.getFolder());
put("ReceivedDate", m.getReceivedDate());

相关文章