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


Java PSTMessage类代码示例

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


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

示例1: getValueAt

import com.pff.PSTMessage; //导入依赖的package包/类
private Object getValueAt(int col, PSTMessage next) {
	try {
        switch (col) {
            case 0:
                return next.getDescriptorNode().descriptorIdentifier+"";
            case 1:
                return next.getSubject();
            case 2:
                return next.getSentRepresentingName() + " <"+ next.getSentRepresentingEmailAddress() +">";
            case 3:
                return next.getReceivedByName() + " <"+next.getReceivedByAddress()+">" + next.getDisplayTo();
            case 4:
                return next.getClientSubmitTime();
            case 5:
                return (next.hasAttachments() ? "Yes" : "No");
            case 10:
               return next ;
            }
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(0);
        }

    return "";
}
 
开发者ID:CoEIA,项目名称:DEM,代码行数:26,代码来源:EmailHandler.java

示例2: getAttachments

import com.pff.PSTMessage; //导入依赖的package包/类
private List<Tuple<String, PSTAttachment>> getAttachments(final PSTMessage email) throws PSTException, IOException {
    int id = email.getDescriptorNode().descriptorIdentifier;
    int numberOfAttachments = email.getNumberOfAttachments();

    List<Tuple<String, PSTAttachment>> attachmentsName = new ArrayList<Tuple<String, PSTAttachment>>();
    
    for(int i=0; i<numberOfAttachments; i++) {
        PSTAttachment attchment = email.getAttachment(i);
        String fileName = this.getId() + "-" + id + "-" + attchment.getLongFilename();
        
        if ( fileName.isEmpty() ) {
            String name = attchment.getFilename();
            if ( name.trim().isEmpty()) continue;
            
            fileName =  this.getId() + "-" + id + "-" + name;
        }
        
        Tuple<String, PSTAttachment> pair = new Tuple<String, PSTAttachment>(fileName, attchment);
        attachmentsName.add(pair);
    }
    
    return attachmentsName;
}
 
开发者ID:CoEIA,项目名称:DEM,代码行数:24,代码来源:OutlookIndexer.java

示例3: updateGuiWithAttachmentsName

import com.pff.PSTMessage; //导入依赖的package包/类
private void updateGuiWithAttachmentsName(final PSTMessage email,
        final String folderName, final List<Tuple<String, PSTAttachment>> attachmentsName) {
    String subject = "";
    String date = "";
    String sentRepresentingName = "";
    String displayTo = "";
    boolean hasAttachment = false;

    try {
        subject = email.getSubject();
        date  = Utilities.getEmptyStringWhenNullDate(email.getClientSubmitTime());
        hasAttachment = email.hasAttachments();
        sentRepresentingName = email.getSentRepresentingName();   
        displayTo = Utilities.getEmptyStringWhenNullString(email.getDisplayTo());
    }
    catch(Exception e ) {
        System.out.println("Exception in outlook gui update!!!");
    }

    List<String> names = new ArrayList<String>();
    for(Tuple<String, PSTAttachment> pair: attachmentsName) {
        names.add(pair.getA());
    }

    String agent = "Outlook: " + getFile().getAbsolutePath();
    EmailCrawlingProgressPanel.EmailCrawlingData data = new EmailCrawlingProgressPanel.EmailCrawlingData(
            agent, folderName, subject, date, String.valueOf(hasAttachment), 
            sentRepresentingName, displayTo, names
    );
}
 
开发者ID:CoEIA,项目名称:DEM,代码行数:31,代码来源:OutlookIndexer.java

示例4: processMessage

import com.pff.PSTMessage; //导入依赖的package包/类
public void processMessage(String folderName, PSTMessage msg) throws PSTException, IOException,
ConfigException {

    String dateKey = FOLDER_DATE.print(msg.getCreationTime().getTime());
    log.info("\tItem: {}; created at {}", msg.getSubject(), dateKey);
    File dateFolder = new File(String.format("%s/%s/%s", this.outputPSTDir.getAbsolutePath(),
            folderName, dateKey));

    if (!dateFolder.exists()) {
        FileUtility.makeDirectory(dateFolder);
    }

    String msgSubj = msg.getSubject();

    if (StringUtils.isBlank(msg.getSubject())) {
        msgSubj = "NO_SUBJECT";
    }

    // Create a folder to contain all the message content.
    File msgFolder = createFolder(dateFolder, msgSubj, msg.getInternetMessageId());

    // Get a list of attachments.
    List<String> attFiles = processAttachments(msg, msgFolder);

    // Create the final text version of the email message.  TODO:  RFC822 dump would be ideal.
    String msgFile = saveMailMessage(msg, msgFolder, attFiles, msgSubj);

    /* TODO: Send msg to listener after attachments are saved, as you might want to report
     * attachment metadata along with msg file.
     */
    if (listener != null) {
        listener.collected(new File(msgFile));
    }
}
 
开发者ID:OpenSextant,项目名称:Xponents,代码行数:35,代码来源:OutlookPSTCrawler.java

示例5: saveMailMessage

import com.pff.PSTMessage; //导入依赖的package包/类
/**
 * Archive a PST Mail Message as a Text file.
 *
 * @param msg PST API message
 * @param msgFolder output folder
 * @param attFiles attachments
 * @param subj subject
 * @return final saved path
 * @throws IOException err saving message
 */
public String saveMailMessage(PSTMessage msg, File msgFolder, List<String> attFiles, String subj)
        throws IOException {
    String msgName = MessageConverter.createSafeFilename(subj);

    String msgText = msg.getBody();
    StringBuilder buf = new StringBuilder();

    // Replicating some of SMTP Header / RFC822 metadata here.
    //
    addHeaderText(buf, "From", getSender(msg));
    addHeaderText(buf, "To", getRecipients(msg));
    addHeaderText(buf, "Subject", subj); // msg.getSubject()
    addHeaderText(buf, "Date", msg.getCreationTime());
    addHeaderText(buf, "MessageId", msg.getInternetMessageId());
    addHeaderText(buf, "X-container-file", this.pst.getName());
    //addHeaderText(buf, "X-saved-on", );
    if (attFiles != null && !attFiles.isEmpty()) {
        addHeaderText(buf, "X-attchments", StringUtils.join(attFiles, "; "));
    }
    buf.append("\n\n");
    buf.append(msgText);
    String savedPath = makePath(msgFolder, msgName + ".txt");
    FileUtility.writeFile(buf.toString(), savedPath);

    return savedPath;

}
 
开发者ID:OpenSextant,项目名称:Xponents,代码行数:38,代码来源:OutlookPSTCrawler.java

示例6: getSender

import com.pff.PSTMessage; //导入依赖的package包/类
private static String getSender(PSTMessage msg) {
    String sentBy = msg.getSenderName();
    String sentByEmail = msg.getSenderEmailAddress();

    if (StringUtils.isNotBlank(sentBy) && StringUtils.isNotBlank(sentByEmail)) {
        return String.format("%s <%s>", sentBy, sentByEmail);
    }
    if (StringUtils.isNotBlank(sentByEmail)) {
        return String.format("<%s>", sentByEmail);
    }
    if (StringUtils.isNotBlank(sentBy)) {
        return sentByEmail;
    }
    return "Unknown Sender";
}
 
开发者ID:OpenSextant,项目名称:Xponents,代码行数:16,代码来源:OutlookPSTCrawler.java

示例7: processAttachments

import com.pff.PSTMessage; //导入依赖的package包/类
/**
 * REFERENCE:  libpst home page, https://code.google.com/p/java-libpst/
 * @author com.pff
 * @author ubaldino -- cleaned up name checks.
 * @param msg  PST API message
 * @param msgFolder output target
 * @return list of attachment filenames
 * @throws PSTException err
 * @throws IOException err
 * @throws ConfigException err
 */
public List<String> processAttachments(PSTMessage msg, File msgFolder) throws PSTException,
IOException, ConfigException {

    int numberOfAttachments = msg.getNumberOfAttachments();
    List<String> attachmentFilenames = new ArrayList<String>();
    for (int x = 0; x < numberOfAttachments; x++) {
        PSTAttachment attach = msg.getAttachment(x);
        // both long and short filenames can be used for attachments
        String filename = attach.getLongFilename();
        if (StringUtils.isBlank(filename)) {
            filename = attach.getFilename();
            if (StringUtils.isBlank(filename)) {
                filename = String.format("attachment%d", x + 1);
            }
        }

        File attPath = new File(String.format("%s/%s", msgFolder.getAbsolutePath(), filename));
        savePSTFile(attach.getFileInputStream(), attPath.getAbsolutePath());

        attachmentFilenames.add(filename);

        if (listener != null) {
            listener.collected(attPath);
        }

        if (converter != null) {
            converter.convert(attPath);
        }
    }

    return attachmentFilenames;
}
 
开发者ID:OpenSextant,项目名称:Xponents,代码行数:44,代码来源:OutlookPSTCrawler.java

示例8: saveAttachmentFromEmail

import com.pff.PSTMessage; //导入依赖的package包/类
/**
 * *
 *
 * @param email
 * @throws FileNotFoundException
 * @throws PSTException
 * @throws IOException
 */
public void saveAttachmentFromEmail(PSTMessage email, FilterInfo filterInfo)
        throws FileNotFoundException, PSTException, IOException, Exception {

    FileOutputStream out = null;
    this.uniqueFileName = null;
    int numberOfAttachments = email.getNumberOfAttachments();
    for (int x = 0; x < numberOfAttachments; x++) {

        PSTAttachment attach = email.getAttachment(x);
        //System.out.println("file size : " + attach.getAttachSize());
        //check file size
        if ((filterInfo.emailAttachFileSizeFrom == 0 || filterInfo.emailAttachFileSizeFrom <= attach.getAttachSize())
                && (filterInfo.emailAttachFileSizeTo == 0 || attach.getAttachSize() <= filterInfo.emailAttachFileSizeTo)) {
            InputStream attachmentStream = attach.getFileInputStream();
            // both long and short filenames can be used for attachments
            String filename = attach.getLongFilename();
            if (filename.isEmpty()) {
                filename = attach.getFilename();
            }
            FileHelper fileHelper = new FileHelper();
            filename = fileHelper.getUniqueFileName(this.emailAttachmentSavePath, filename);
            String fullFileName = this.emailAttachmentSavePath + filename;

            out = new FileOutputStream(fullFileName);
            // 8176 is the block size used internally and should give the best performance
            int bufferSize = 8176;
            byte[] buffer = new byte[bufferSize];
            int count = attachmentStream.read(buffer);
            while (count == bufferSize) {
                out.write(buffer);
                count = attachmentStream.read(buffer);
            }
            byte[] endBuffer = new byte[count];
            System.arraycopy(buffer, 0, endBuffer, 0, count);
            out.write(endBuffer);
            out.close();
            //System.out.println("saved fullFileName : " + fullFileName);
            attachmentStream.close();
            //extract if zip file
            if ("zip".equals(FilenameUtils.getExtension(filename))) {
                UnZipHelper unZipHelper = new UnZipHelper();
                unZipHelper.unZipFolder(fullFileName, this.emailAttachmentSavePath);

            }
        }
    }
}
 
开发者ID:ranjeet-floyd,项目名称:pst-email-save-attachment,代码行数:56,代码来源:PSTFileHelper.java

示例9: getMessage

import com.pff.PSTMessage; //导入依赖的package包/类
private PSTMessage getMessage (long id)throws IOException, PSTException {
    return (PSTMessage) PSTObject.detectAndLoadPSTObject(pstFile, id);
}
 
开发者ID:CoEIA,项目名称:DEM,代码行数:4,代码来源:EmailPanel.java

示例10: getFolder

import com.pff.PSTMessage; //导入依赖的package包/类
private HashMap<String,Integer>  getFolder (String folderName, String from, String to) throws ParseException {
    ArrayList<MessageHeader> map = EmailReader.getInstance(pstFile,path,null);

    if ( map == null)
        return null;

    map = filterList(folderName, map);
    
    String user = getUserName() ;

    if ( user == null) {
        logger.log(Level.INFO, "User Name For OST: " + path + " is null");
        return null ;
    }
    
    HashMap<String,Integer> data = new HashMap<String,Integer>();

    DateFormat df = new SimpleDateFormat("d/M/yyyy");
    Date fromDate = df.parse(from);
    Date toDate   = df.parse(to);
    
   try {
        int row = map.size();

        for (int i=0 ; i<row ; i++ ) {
            MessageHeader m = map.get(i);
            PSTMessage msg = getMessage(m.getID());
            
            String col2 = (String) getValueAt(2,msg);
            String col3 = (String) getValueAt(3,msg);
            Date messageDate = (Date) getValueAt(4,msg);

            if ( ! messageDate.after(fromDate) || ! messageDate.before(toDate) ) {
                continue ;
            }

            Tuple<String,ArrayList<String>> tuple = null;

            if ( folderName.equals("Inbox") ) {
                tuple =  getSendingMessages(col2,col3);
                String senderName = tuple.getA();

                if ( Utilities.isFound(tuple.getB(),user)) {
                    if ( data.get(senderName) == null)
                        data.put(senderName, 1);
                    else
                        data.put(senderName, data.get(senderName) + 1);
                }
            }
            else if ( folderName.equals("Sent Items")) {
                tuple = getReceiverNames(col2,col3);

                for (String s: tuple.getB()) {
                    if ( data.get(s) == null)
                        data.put(s,1);
                    else
                        data.put(s,data.get(s)+1);
                }
            }
        }
   }
   catch (Exception e){
       e.printStackTrace();
       logger.log(Level.SEVERE, "Uncaught exception", e);
   }

   return ( data );
}
 
开发者ID:CoEIA,项目名称:DEM,代码行数:69,代码来源:EmailHandler.java

示例11: getLocationsFolder

import com.pff.PSTMessage; //导入依赖的package包/类
private HashMap<String,Integer>  getLocationsFolder (String folderName, String from, String to) throws ParseException {
    ArrayList<MessageHeader> map = EmailReader.getInstance(pstFile,path,null);

    if ( map == null)
        return null;

    map = filterList(folderName, map);
    HashMap<String,Integer> data = new HashMap<String,Integer>();

    if ( map == null ) {
        logger.log(Level.INFO, "Map For OST: " + path + " is null");
        return null ;
    }
    
    DateFormat df = new SimpleDateFormat("d/M/yyyy");
    Date fromDate = df.parse(from);
    Date toDate   = df.parse(to);

    try {
        int row = map.size();

        for (int i=0 ; i<row ; i++ ) {
            MessageHeader m = map.get(i);
            PSTMessage msg = getMessage(m.getID());
            
            Date messageDate = (Date) getValueAt(4,msg);

            if ( ! messageDate.after(fromDate) || ! messageDate.before(toDate) ) {
                continue ;
            }

            if ( folderName.equals("Inbox") ) {
                if ( isLocal(msg.getSenderAddrtype()) ) {
                    String line = getLine(msg.getTransportMessageHeaders());

                    if ( ! line.startsWith("Received") )
                        continue ;

                    String domain = getLocalDomain(line);
                    String ip = getLocalIp(line);

                    if ( data.get(domain) == null)
                        data.put(domain, 1);
                    else
                        data.put(domain, data.get(domain) + 1);
                }
                else {
                    String country = getOutIp(msg.getTransportMessageHeaders());

                    if ( data.get(country) == null)
                        data.put(country, 1);
                    else
                        data.put(country, data.get(country) + 1);

                }
            }
            else if ( folderName.equals("Sent Items")) {
            }
        }
   }
   catch (Exception e){
       e.printStackTrace();
       logger.log(Level.SEVERE, "Uncaught exception", e);
   }

   return ( data );
}
 
开发者ID:CoEIA,项目名称:DEM,代码行数:68,代码来源:EmailHandler.java

示例12: getESPFolder

import com.pff.PSTMessage; //导入依赖的package包/类
private HashMap<String,Integer>  getESPFolder (String folderName, String from, String to) throws ParseException {
    ArrayList<MessageHeader> map = EmailReader.getInstance(pstFile,path,null);

    if ( map == null)
        return null;

    map = filterList(folderName, map);
    
    HashMap<String,Integer> data = new HashMap<String,Integer>();

    if ( map == null) {
        logger.log(Level.INFO, "Map For OST: " + path + " is null");
        return null ;
    }
    
    DateFormat df = new SimpleDateFormat("d/M/yyyy");
    Date fromDate = df.parse(from);
    Date toDate   = df.parse(to);

    try {
        int row = map.size();

        for (int i=0 ; i<row ; i++ ) {
            MessageHeader m = map.get(i);
            PSTMessage msg = getMessage(m.getID());
            
            String col2 = (String) getValueAt(2,msg);
            Date messageDate = (Date) getValueAt(4,msg);

            if ( ! messageDate.after(fromDate) || ! messageDate.before(toDate) ) {
                continue ;
            }

            String esp = getESP(col2);

            if ( folderName.equals("Inbox") ) {
                if ( data.get(esp) == null )
                    data.put(esp,1);
                else
                    data.put(esp, data.get(esp) + 1);
            }
            else if ( folderName.equals("Sent Items")) {
                if ( data.get(esp) == null )
                    data.put(esp,1);
                else
                    data.put(esp, data.get(esp) + 1);
            }
        }
   }
   catch (Exception e){
       e.printStackTrace();
       logger.log(Level.SEVERE, "Uncaught exception", e);
   }

   return ( data );
}
 
开发者ID:CoEIA,项目名称:DEM,代码行数:57,代码来源:EmailHandler.java

示例13: processFolder

import com.pff.PSTMessage; //导入依赖的package包/类
/**
 *
 * @param folder  found folder from PST
 * @throws PSTException PST API error
 * @throws IOException I/O failure
 * @throws ConfigException  XText configuration error
 */
protected void processFolder(PSTFolder folder) throws PSTException, IOException,
ConfigException {
    log.info("Folder:" + folder.getDisplayName());
    ++depth;
    if (depth >= maxDepth) {
        --depth;
        log.error("MAX DEPTH reached. Avoid infinite recursion");
        return;
    }
    if (folder.hasSubfolders()) {
        Vector<PSTFolder> children = folder.getSubFolders();
        for (PSTFolder child : children) {
            processFolder(child);
        }
    }

    log.info("\t\tProcessing content items");

    int count = folder.getContentCount();
    if (count > 0) {
        PSTObject msg = null;
        while ((msg = folder.getNextChild()) != null) {
            // As libPST is organized with PSTMessage (email) being a base class, it must only be used as a default.
            // Try all other subclasses first.
            //
            String savedItem = null;
            if (msg instanceof PSTContact) {
                savedItem = processContact("Contacts", folder.getDisplayName(),
                        (PSTContact) msg);
            } else if (msg instanceof PSTDistList) {
                savedItem = processDistList("Lists", folder.getDisplayName(), (PSTDistList) msg);
            } else if (msg instanceof PSTAppointment) {
                savedItem = processAppointment("Appointments", folder.getDisplayName(),
                        (PSTAppointment) msg);
            } else if (msg instanceof PSTMessage) {
                processMessage(folder.getDisplayName(), (PSTMessage) msg);
            } else {
                log.info("\tItem: {}; Type:{} created at {}", msg.getDisplayName(),
                        msg.getMessageClass(), msg.getCreationTime());
            }

            if (savedItem != null && listener != null) {
                listener.collected(new File(savedItem));
            }
        }
    }
    --depth;
}
 
开发者ID:OpenSextant,项目名称:Xponents,代码行数:56,代码来源:OutlookPSTCrawler.java

示例14: getRecipients

import com.pff.PSTMessage; //导入依赖的package包/类
private static String getRecipients(PSTMessage msg) {
    return msg.getRecipientsString();
}
 
开发者ID:OpenSextant,项目名称:Xponents,代码行数:4,代码来源:OutlookPSTCrawler.java


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