【问题标题】:Outlook + Perl + Win32::Ole: How do you select calendar entries sorted by date?Outlook + Perl + Win32::Ole:如何选择按日期排序的日历条目?
【发布时间】:2010-09-09 21:14:39
【问题描述】:

当前代码如下打开一个 Outlook 日历数据库:

my $outlook = Win32::OLE->GetActiveObject('Outlook.Application') || Win32::OLE->new('Outlook.Application', 'Quit');

my $namespace = $outlook->GetNamespace("MAPI");

## only fetch entries from Jan 1, 2007 onwards
my $restrictDates = "[Start] >= '01/01/2007'";  

【问题讨论】:

    标签: perl winapi outlook


    【解决方案1】:

    由于您没有显示获取对象日期的代码,因此如果不了解您尝试访问的 Outlook 对象,就无法回答这个问题。

    如果您有一组对象,您可以按日期对它们进行排序,并在某个对象之前过滤它们。

    my $sub = sub {
           my $ad = $a->date_string_accessor;
           my $bd = $b->date_string_accessor;
           $ad =~ s:(\d+)/(\d+)/(\d+):$3 . sprintf('%0d', $1) . sprintf('%0d', $2):e;
           $bd =~ s:(\d+)/(\d+)/(\d+):$3 . sprintf('%0d', $1) . sprintf('%0d', $2):e;
           return $ad cmp $bd;
    };
    
    my @sorted = sort $sub @unsorted;
    
    print join("\n", @sorted);
    

    但在我看来,您应该使用应用程序本身来执行此操作——大概 Outlook 具有某种查询/排序功能。

    【讨论】:

      猜你喜欢
      • 2014-02-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-08
      • 1970-01-01
      • 2011-03-18
      • 2016-04-04
      • 1970-01-01
      相关资源
      最近更新 更多