如何使用Perl列出Outlook文件夹



我需要帮助使用 Perl 列出 Outlook 收件箱中的所有文件夹。我使用此代码尝试了它,但无法输出任何打印。我是Perl的初学者,我找不到任何简单的解决方案。

#!/usr/bin/perl
use Win32::OLE qw(in with);
use Win32::OLE::Const 'Microsoft Outlook';
use Win32::OLE::Variant;
my $OL = Win32::OLE->GetActiveObject('Outlook.Application');
my $namespace = $OL->GetNamespace('MAPI');
my $all_folders = $namespace->all_folders();
print $all_folders;

所以我终于找到了我的问题的解决方案。因为我在工作中使用 outlook,所以它有一些预定义的设置。我们与其他国家的同事一起测试了它,我们在同一家公司工作,但他的前景不同。所以就我而言,我有三个文件夹。

email.address@domain.com档案email.address@domain.com

不确定为什么我的地址在那里列出两次,但无论如何,我所要做的就是连接到我的电子邮件地址,然后列出所有文件夹。此处的示例是列出收件箱文件夹中的每个子文件夹。

use strict;
#use warnings;

### This Perl Modules should be installed!
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel'; # instead of the constants
use Win32::OLE::Const 'Microsoft Outlook';
use Win32::OLE qw(in with);
use Win32::OLE::Variant;

use IO::File;
use IO::Handle;
use Date::Calc qw(:all);
#jumps to outlook
my $OL = Win32::OLE->GetActiveObject('Outlook.Application');
#this is predefined namespace   
my $namespace = $OL->GetNamespace('MAPI');
#loop through all folders inside of the INBOX folder   
foreach my $i (1..$namespace->Folders->Count) {
       my $folder = $namespace->Folders("email.address@domain.com")->Folders("Inbox")->Folders($i)->Name;
       print $folder, "....n";                    
    }

问题解决了:)。

还有一个注释 ->您的 Outlook 中可能有不同的设置,因此在这种情况下,您可以删除第一个文件夹 - 文件夹("email.address\@domain.com"( - 或者至少这是它与我的同事 Outlook 一起工作的方式。

最新更新