Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Notes::OLE: Doc-Dumper?

by mhi (Friar)
on Jul 07, 2004 at 12:30 UTC ( [id://372361]=note: print w/replies, xml ) Need Help??


in reply to Notes::OLE: Doc-Dumper?

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.

Replies are listed 'Best First'.
Re^2: Notes::OLE: Doc-Dumper?
by Zero_Flop (Pilgrim) on Jul 08, 2004 at 00:53 UTC
    Type property ->returns constants like ATTACHMENT, DATETIMES, HTML, EMBEDDEDOBJECT, RICHTEXT, TEXT...

    TypeName -> type of data each element in the array is, like NotesDateRange or DateTime. This can also be used for the other fields.

    Zero_Flop
      I only see the type property returning numeric constants such as 1024 for DateTime. Am I looking at it the wrong way? But that's not a problem as these codes are documented.

      How would you use the LotusScript function TypeName in the OLE-Interface?
      Using $dtelem->{TypeName} in the code above delivers an error Win32::OLE(0.1502) error 0x80020003: "Member not found" in METHOD/PROPERTYGET "TypeName" at ./dumpdocs.pl line 38 so it's obviously not implemented as a method on the array element... This is no fun poking around in the dark. :-(

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://372361]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (1)
As of 2024-04-19 00:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found