简体   繁体   English

Outlook + Perl + Win32 :: Ole:如何选择按日期排序的日历项?

[英]Outlook + Perl + Win32::Ole: How do you select calendar entries sorted by date?

Current code opens up an Outlook Calendar database as follow: 当前代码打开一个Outlook Calendar数据库,如下所示:

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'";  

Since you don't show the code that gets the date of your object, this question is impossible to answer without some knowledge of the Outlook object you are trying to access. 由于您没有显示获取对象日期的代码,因此如果不了解您要访问的Outlook对象,就无法回答此问题。

If you have an array of objects you can sort them by date and filter ones prior to a certain one. 如果您有一组对象,则可以按日期对它们进行排序,并过滤某个对象之前的对象。

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);

But it would seem to me that you should use the application itself to do this -- presumably Outlook has some sort of query/sort functionality. 但是在我看来,您应该使用应用程序本身来执行此操作-大概Outlook具有某种查询/排序功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM