2014-07-08 29 views
2

我已經設法在Outlook中添加文件夾,但無法解決如何移動它們。是否可以使用Win32 :: OLE移動Outlook文件夾?

#!/usr/bin/perl 
use strict; 
use warnings; 

use Win32::OLE; 
use Win32::OLE::Const 'Microsoft Outlook'; 

# use existing instance if Outlook is already running, or launch a new one 
    my $Outlook; 
eval {$Outlook = Win32::OLE->GetActiveObject('Outlook.Application')}; 
die "Outlook not installed" if [email protected]; 
unless (defined $Outlook) { 
    $Outlook = Win32::OLE->new('Outlook.Application', sub {$_[0]->Quit;}) 
    or die "Oops, cannot start Outlook"; 
} 
my $namespace = $Outlook->GetNamespace("MAPI"); 

#my $Folder = $namespace->Folders("backupadmin")->Folders(
    # "Inbox")->Folders->Add("test"); 

my $Folder = $namespace->Folders("backupadmin")->Folders(
    "Inbox")->Folders("test")->MoveTo("test1");  
+0

展望VB命名空間看起來很冒險的;你的目標是重命名文件夾,還是重新保存它?如果目標是命名的,像'...-> Folders(「test」) - > Name =「test1」'可能會起作用(或者類似'setName'等適當語法)。 [Renaming reference](http://www.pcreview.co.uk/forums/rename-folder-outlook-inbox-t3031265.html) – abiessu

+0

更準確地說,'my $ Folder = $ namespace-> Folders(「backupadmin」) - >文件夾(「收件箱」) - >文件夾(「測試」) - > {「名稱」} =「test1」;'(再次假設目的是重命名文件夾,而不是重新文件夾) ...->文件夾(「測試」) - > SetProperty('名稱','test1')' – abiessu

+0

請注意,還有其他評論意見表明,一旦這樣的重命名已應用,必須刷新也看到結果。 – abiessu

回答

0

如果你使用流行的Outlook贖回庫,你可以檢索你要移動,然後調用這個文件夾的RDO文件夾對象:我不拋出任何警告,不移動文件夾中的代碼以目標RDO文件夾作爲參數的MoveTo方法。對於一些示例Perl代碼,您可以引用使用Win32::OLE和Outlook Redemption訪問RDO文件夾對象的Email::PST::Win32 CPAN模塊。

展望贖回:http://www.dimastr.com/redemption/home.htm

RDO文件夾通過MoveTo方法:http://www.dimastr.com/redemption/rdo/rdofolder.htm

電子郵件:: PST :: Win32的:https://metacpan.org/release/Email-PST-Win32

相關問題