首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2EE开发 >

jacob操作outlook,该如何处理

2012-12-30 
jacob操作outlook大家好,我想知道为explorer 里 除了outlook Selection(当前选中)还有哪些选项,比如所有的

jacob操作outlook
大家好,我想知道为explorer 里 除了outlook Selection(当前选中)还有哪些选项,比如所有的,比如未读的,已读的,删除的。草稿箱。 这些参数要怎么写,我怎么知道它里面有哪些参数? 跪求! 我很奇怪既然是固定参数为什么不定义一个常量类。


 ActiveXComponent xl = new ActiveXComponent("Outlook.Application");  
      
         Dispatch explorer = Dispatch.get(xl,"ActiveExplorer").toDispatch();  
         Dispatch selection = Dispatch.get(explorer, "Selection").toDispatch();  
         Variant count = Dispatch.get(selection, "Count");  
   
         for (int mailIndex = 1; mailIndex <= count.toInt(); mailIndex++ ) {  
             Dispatch mailItem = Dispatch.call(selection, "Item", new Variant(mailIndex)).toDispatch();  
   
             Variant senderName = Dispatch.get(mailItem, "SenderName");  
             Variant subject = Dispatch.get(mailItem, "Subject");  
             Variant body = Dispatch.get(mailItem, "HTMLBody");  
       
             String emailFileName = subject.toString() +".txt";    
               
             try {  
                 File email = new File(emailFileName);  
                 PrintWriter writer = new PrintWriter( new FileWriter(email) );  
                 writer.println("From: "+ senderName );  
                 writer.println("Subject: "+ subject);  
                 writer.println("");  
                 writer.print( body );  
                 writer.close();  
             }  
             catch (IOException e) {  
                 System.out.println("IOException writing e-mail with subject: '"+ subject +"'");  
                 continue;  
             }  
   


             Dispatch attachments = Dispatch.get(mailItem, "Attachments").toDispatch();  
             Variant attachmentCount = Dispatch.get(attachments, "Count");  
   
             if ( attachmentCount.toInt() > 0 ) {  
                 for( int attachmentIndex = 1; attachmentIndex<=attachmentCount.toInt(); attachmentIndex++ ) {  
                     Dispatch attachment = Dispatch.call(attachments, "Item", new Variant(attachmentIndex)).toDispatch();  
                     Variant fileNameVariant = Dispatch.get(attachment, "FileName");  
                     String fileName = fileNameVariant.toString();  
               
                     Variant saveResult = Dispatch.call(attachment, "SaveAsFile", "F:\"+fileName);  
                 }  
             }  
           
         }  



[解决办法]
jacob操作outlook,该如何处理

热点排行