Ok, I wrote it and tested it with form=appointment-documents, but it might work with pretty much any notes document (see code below).
Thanks diotalevi and Zero_Flop for your insights!
Since I don't need to look at more than a handful of documents, I'll stick to GetNthDocument for the time being.
As it turns out, the most difficult thing to analyze is the array returned by GetItemValueDateTimeArray since it can contain either NotesDateRange or DateTime. Is there any better way of telling which it is other than looking at the ItemName like I've done here?
#!/usr/bin/perl -w
use strict;
use Notes::OLE;
use vars qw( $SERVER );
$SERVER=''; # empty when querying local client
my $mailfile='mail\myshortname.nsf';
my $maxdocs=50; # 0=all
my $maxshowdocs=1;
my $n="\n";
my $db = $S->GetDatabase($SERVER, $mailfile);
my $docs=$db->Search( "Form = \"Appointment\"" , $DT, $maxdocs); # "Ap
+pointment"(calendar) or "Memo"(email)
my $count = $docs->Count;
print "found ",$count," docs.\n\n";
for(my $i=1;$i<=$maxshowdocs and $i<=$count ;++$i){
print "############## Document $i ###################\n\n";
my $doc=$docs->GetNthDocument($i);
my $items=$doc->Items;
foreach my $item (@$items){
my $name=$item->Name;
my $type=$item->Type;
print "ItemName: $name / ItemType: $type";
my $val;
if( $type==1024 ){ # Type-Value for DateTime Type
my $dtarr=$doc->GetItemValueDateTimeArray($name);
print " [", scalar @$dtarr," value(s) in Item]";
print " (DateTime) ";
foreach my $dtelem (@$dtarr){
if( $name=~/Range$/ ){ # DateTime or NotesDateRange? *****
$val .=
($dtelem->{StartDateTime}->{LocalTime})." - ".
($dtelem->{EndDateTime}->{LocalTime})." ";
}else{
$val .= ($dtelem->{LocalTime})." ";
}
}
}else{
$val=$doc->GetItemValue($name);
print " [", scalar @$val," value(s) in Item]";
$val=join($n, @$val);
}
print "$n$val$n$n";
}
}
Update: Added smartass comment as first sentence. ;-) Made first sentence into a new and improved first paragraph.