Important alert: (current site time 7/15/2013 9:30:57 PM EDT)
 

VB icon

Get docs in notes db

Email
Submitted on: 7/30/2000 12:29:23 AM
By: Found on the World Wide Web 
Level: Intermediate
User Rating: Unrated
Compatibility: 5.0 (all versions), 4.0 (all versions), 3.0 (all versions), Pre 3.0
Views: 8031
 
     This script gets all the documents in a notes database and prints out a document by number
 
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
				
=**************************************
= Name: Get docs in notes db
= Description:This script gets all the documents in a notes database and prints out a document by number
= By: Found on the World Wide Web
=**************************************

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->new('Notes.NotesSession')or die "Cannot start Lotus Notes Session object.\n";
my $Database = $Notes->GetDatabase("$server", "mail\$userid.nsf") or die "Could not open database.\n";
my $AllDocuments = $Database->AllDocuments;
my $Count = $AllDocuments->Count;
my @counted = (1 .. $Count);
print "\n\nPlease wait while the notes mail file is processed . . .\n\n";
foreach $doc (@counted) {
	$Document = $AllDocuments->GetNthDocument($doc);
	$val = sprintf "$doc. %s", $Document->GetFirstItem('Subject')->{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 = <STDIN>);
$choice =~ tr/a-z/A-Z/;
	if ($choice eq "I") {
	&idex;	
	}
	if ($choice eq "B") {
	&body;
	}
	
	if ($choice eq "Q") {
	exit;	
	}
}
sub idex {
my $docnum;
print "What is the first number you would like to see? ";
chomp($docnum = <STDIN>);
my $limit = $docnum + 5;
	for ($docnum; $docnum < $limit; $docnum++) {
	print "Number: $doc Subject: $noteshash{$docnum}\n";
	}
}
	
sub body {
print "What document would you like to look at? ";
chomp($doc = <STDIN>);
$Document = $AllDocuments->GetNthDocument($doc);
my @Attributes = $Buffer->info();
printf "\n\n$doc. %s\n", $Document->GetFirstItem('Body')->{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


Other 100 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Intermediate category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments

 There are no comments on this submission.
 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)
 

To post feedback, first please login.