<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">use strict;
use Win32::OLE;

my %count;
my $Buffer;
my $choice;
my $doc;
my $Document;
my %noteshash = ();
my $num;
my $userid = "x";
my $search;
my $server = "x/x";
my $val;
my $VERSION = '1.0';

my $Notes = Win32::OLE-&gt;new('Notes.NotesSession')or die "Cannot start Lotus Notes Session object.\n";
my $Database = $Notes-&gt;GetDatabase("$server", "mail\$userid.nsf") or die "Could not open database.\n";
my $AllDocuments = $Database-&gt;AllDocuments;
my $Count = $AllDocuments-&gt;Count;
my @counted = (1 .. $Count);

print "\n\nPlease wait while the notes mail file is processed . . .\n\n";
foreach $doc (@counted) {
	$Document = $AllDocuments-&gt;GetNthDocument($doc);
	$val = sprintf "$doc. %s", $Document-&gt;GetFirstItem('Subject')-&gt;{Text};
	$noteshash{$doc}=$val;
}

while ($choice ne "Q"){
print "\n\nWelcome to the Perl Notes client.\n";
print "Press I to look at an index of email.\n";
print "Press B to look at the body of a message.\n";
print "Press Q to exit the program.\n";
chomp($choice = &lt;STDIN&gt;);
$choice =~ tr/a-z/A-Z/;

	if ($choice eq "I") {
	&amp;idex;	
	}

	if ($choice eq "B") {
	&amp;body;
	}
	
	if ($choice eq "Q") {
	exit;	
	}
}

sub idex {
my $docnum;

print "What is the first number you would like to see? ";
chomp($docnum = &lt;STDIN&gt;);

my $limit = $docnum + 5;
	for ($docnum; $docnum &lt; $limit; $docnum++) {
	print "Number: $doc Subject: $noteshash{$docnum}\n";
	}
}
	
sub body {
print "What document would you like to look at? ";
chomp($doc = &lt;STDIN&gt;);
$Document = $AllDocuments-&gt;GetNthDocument($doc);
my @Attributes = $Buffer-&gt;info();
printf "\n\n$doc. %s\n", $Document-&gt;GetFirstItem('Body')-&gt;{Text};
}

=head1 NAME

getnotes - This script gets all the documents in a notes database and prints out a document by number.

=head1 DESCRIPTION

This is my first attempt at accessing notes databases from perl.  I can think of some interesting uses for notes and perl.
I would specifically like to pull an email and compare it with a list from another file.  This script is still in beta.

=head1 README

This script gets all the documents in a notes database and prints out a document by number.

=head1 PREREQUISITES

This script has a few requirements.  You will need the Win32::OLE module.
You will also need to change the values for nsf and server.

=head1 COREQUISITES

None

=pod OSNAMES

MSWin32

=pod SCRIPT CATEGORIES

Win32

=cut







</pre></body></html>