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


Java IMAPMessage类代码示例

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


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

示例1: writeSubjectToOutPutStream

import com.sun.mail.imap.IMAPMessage; //导入依赖的package包/类
/**
 * 将每封邮件的主题写入输出流中
 * @param message
 * @throws MessagingException 
 */
private void writeSubjectToOutPutStream(Message message) throws Exception {
	if(message == null){
		return ;
	}
	IMAPMessage imapMessage = (IMAPMessage )message;
	try{
		
		//POP3ReceiveMailTest.parseMessage(message);
		call(imapMessage);
		// TODO Auto-generated method stub
		//System.out.println("邮件主题为:"+imapMessage.getSubject());
		//System.out.println(" 内容为:"+imapMessage.getContentID());
	}catch(Exception e){
		e.printStackTrace();
	}
    Thread.sleep(1000);
}
 
开发者ID:xiaomin0322,项目名称:alimama,代码行数:23,代码来源:SimpleSendReceiveMessage.java

示例2: getNextBatch

import com.sun.mail.imap.IMAPMessage; //导入依赖的package包/类
private void getNextBatch(int batchSize, Folder folder)
    throws MessagingException {
  // after each batch invalidate cache
  if (messagesInCurBatch != null) {
    for (Message m : messagesInCurBatch) {
      if (m instanceof IMAPMessage) ((IMAPMessage) m).invalidateHeaders();
    }
  }
  int lastMsg = (currentBatch + 1) * batchSize;
  lastMsg = lastMsg > totalInFolder ? totalInFolder : lastMsg;
  messagesInCurBatch = folder.getMessages(currentBatch * batchSize + 1,
      lastMsg);
  folder.fetch(messagesInCurBatch, fp);
  current = 0;
  currentBatch++;
  LOG.info("Current Batch  : " + currentBatch);
  LOG.info("Messages in this batch  : " + messagesInCurBatch.length);
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:MailEntityProcessor.java

示例3: getNextBatch

import com.sun.mail.imap.IMAPMessage; //导入依赖的package包/类
private void getNextBatch(int batchSize, Folder folder) throws MessagingException {
  // after each batch invalidate cache
  if (messagesInCurBatch != null) {
    for (Message m : messagesInCurBatch) {
      if (m instanceof IMAPMessage)
        ((IMAPMessage) m).invalidateHeaders();
    }
  }
  int lastMsg = (currentBatch + 1) * batchSize;
  lastMsg = lastMsg > totalInFolder ? totalInFolder : lastMsg;
  messagesInCurBatch = folder.getMessages(currentBatch * batchSize + 1, lastMsg);
  folder.fetch(messagesInCurBatch, fp);
  current = 0;
  currentBatch++;
  LOG.info("Current Batch  : " + currentBatch);
  LOG.info("Messages in this batch  : " + messagesInCurBatch.length);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:18,代码来源:MailEntityProcessor.java

示例4: MessageId

import com.sun.mail.imap.IMAPMessage; //导入依赖的package包/类
/**
 * All of this process could be done just by using the ENVELOPE response from the IMAP fetch
 * command. The problem is that ENVELOPE is not consistent amongst different servers, so
 * sometimes a same e-mail will have different envelope responses in different servers, so they
 * will duplicate.
 * 
 * It's a pity because fetching all of the HEADERS is a performance HOG
 *
 * @param message
 * @throws com.marcnuri.mnimapsync.store.MessageId.MessageIdException
 */
public MessageId(IMAPMessage message) throws MessageIdException {
    try {
        final String[] idHeader = message.getHeader(HEADER_MESSAGE_ID);
        final String[] subjectHeader = message.getHeader(HEADER_SUBJECT);
        this.messageId = idHeader != null && idHeader.length > 0
                ? idHeader[0].trim().replaceAll("[^a-zA-Z0-9\\\\.\\\\-\\\\@]", "")
                : "";
        //Irregular mails have more than one header for From or To fields
        //This can cause that different servers respond differently
        this.from = parseAddress(message.getHeader(HEADER_FROM));
        this.to = parseAddress(message.getHeader(HEADER_TO));
        //Regular subject may have some problems when using non ascii characters
        //Loss of precision, but I don't think it's necessary
        this.subject = subjectHeader != null && subjectHeader.length > 0
                ? subjectHeader[0].replaceAll("[^a-zA-Z0-9\\\\.\\\\-]", "")
                : "";
        if (this.messageId.equals("") && subject.equals("")) {
            throw new MessageIdException("No good fields for Id", null);
        }
    } catch (MessagingException messagingException) {
        throw new MessageIdException("Messaging Exception", messagingException);
    }
}
 
开发者ID:manusa,项目名称:mnIMAPSync,代码行数:35,代码来源:MessageId.java

示例5: processUndeletedMessages

import com.sun.mail.imap.IMAPMessage; //导入依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
protected void processUndeletedMessages(MailMessageWorker worker) {
    if (folder != null) {
        try {
            Message[] messages = folder.getMessages();
            for (Message message : messages) {
                if (!message.isExpunged() && !message.isSet(Flags.Flag.DELETED)) {
                    worker.processMailMessage(message);
                }
                if (message instanceof IMAPMessage) {
                    // kind of ugly, but Java Mail keeps references to the headers until the
                    // folder is closed which can lead to an OOM exception. By invalidating the
                    // headers these references are removed.

                    // TODO maybe we should close the folder as soon as we handled the
                    // unprocessed messages and reopen and attach the AddedListener afterwards?
                    // But would be "blind" for a short while. Could also try to work with
                    // HIGHESTMODSEQ if the server supports it.
                    ((IMAPMessage) message).invalidateHeaders();
                }
            }

        } catch (MessagingException e) {
            LOGGER.error(e.getMessage(), e);
        }
    }
}
 
开发者ID:Communote,项目名称:communote-server,代码行数:31,代码来源:ImapMailboxConnection.java

示例6: getMessageId

import com.sun.mail.imap.IMAPMessage; //导入依赖的package包/类
@Override
protected String getMessageId(Folder folder, Message message)
		throws MessagingException {
	if (!(message instanceof IMAPMessage))
		return null;
	return ((IMAPMessage) message).getMessageID();
}
 
开发者ID:jaeksoft,项目名称:opensearchserver,代码行数:8,代码来源:IMAP4Crawler.java

示例7: run

import com.sun.mail.imap.IMAPMessage; //导入依赖的package包/类
public void run() {
    long deleted = 0l, skipped = 0l;
    try {
        final Folder targetFolder = storeDeleter.getTargetStore().getFolder(targetFolderName);
        //Opens a new connection per Thread
        targetFolder.open(Folder.READ_WRITE);
        final Message[] targetMessages = targetFolder.getMessages(start, end);
        targetFolder.fetch(targetMessages, MessageId.addHeaders(new FetchProfile()));
        for (Message message : targetMessages) {
            try {
                final MessageId id = new MessageId((IMAPMessage) message);
                if (!sourceFolderMessages.contains(id)) {
                    message.setFlag(Flags.Flag.DELETED, true);
                    deleted++;
                } else {
                    skipped++;
                }
            } catch (MessageId.MessageIdException ex) {
                //Usually messages that ran into this exception are spammy, so we skip them.
                skipped++;
            }
        }
        //Close folder and expunge flagged messages
        //Expunge only if folder is read write
        if (targetFolder.getMode() == Folder.READ_ONLY) {
            targetFolder.close(false);
        } else {
            targetFolder.close(expunge);
        }
    } catch (MessagingException messagingException) {
        Logger.getLogger(StoreIndex.class.getName()).log(Level.SEVERE, null, messagingException);
    }
    storeDeleter.updatedMessagesDeletedCount(deleted);
    storeDeleter.updateMessagesSkippedCount(skipped);
}
 
开发者ID:manusa,项目名称:mnIMAPSync,代码行数:36,代码来源:MessageDeleter.java

示例8: run

import com.sun.mail.imap.IMAPMessage; //导入依赖的package包/类
public void run() {
    long indexedMessages = 0l, skippedMessages = 0l;
    try {
        final Folder folder = store.getFolder(folderName);
        folder.open(Folder.READ_ONLY);
        final Message[] messages = folder.getMessages(start, end);
        folder.fetch(messages, MessageId.addHeaders(new FetchProfile()));
        for (Message message : messages) {
            //Don't bother crawling if index has exceptions. Process won't continue
            if (storeIndex.hasCrawlException()) {
                return;
            }
            try {
                final MessageId messageId = new MessageId((IMAPMessage) message);
                if (storeIndex.getFolderMessages(folderName).add(messageId)) {
                    indexedMessages++;
                } else {
                    skippedMessages++;
                }
            } catch (MessageId.MessageIdException ex) {
                if (ex.getCause() != null) {
                    throw new MessagingException();
                }
                skippedMessages++;
            }
        }
        folder.close(false);
    } catch (MessagingException messagingException) {
        storeIndex.getCrawlExceptions().add(messagingException);
    }
    storeIndex.updatedIndexedMessageCount(indexedMessages);
    storeIndex.updatedSkippedMessageCount(skippedMessages);
}
 
开发者ID:manusa,项目名称:mnIMAPSync,代码行数:34,代码来源:FolderCrawler.java


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