Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Lotus Notes

by Cycle Boy (Initiate)
on Apr 25, 2002 at 09:22 UTC ( [id://161897]=perlquestion: print w/replies, xml ) Need Help??

Cycle Boy has asked for the wisdom of the Perl Monks concerning the following question:

Can anyone offer a snippet of Perl that shows how to create a lotus notes document, populate some fields, save and close the document, and database?????

I found some code on how to send notes and how to count documents but I can't find anything anywhere on creating and populating documents....

I've done C++ Notes API stuff before but I would prefer to use Perl and I'm getting tired playing guess the syntax here so if anyone can help it would be very much appreciated.

Thanks for your help.


Replies are listed 'Best First'.
Re: Lotus Notes
by dhable (Monk) on Apr 25, 2002 at 12:37 UTC
    I've only started to use interface with a Notes database so I'm not sure how helpful this will be. I know that you can connect to the Notes DB using ODBC, so DBD::ODBC should contain all of the support you need to connect to the database and issue commands.

    This next part is where my advise starts to fade into the mist. It is my understanding that you can issue SQL-92 compliant commands (like CREATE TABLE or INSERT INTO) using the ODBC. I'm not sure if this is a navtive feature, but there is a package called Notes SQL that you can download and install to enable this SQL-92 functionality.
Re: Lotus Notes
by t'mo (Pilgrim) on Apr 25, 2002 at 20:37 UTC

    Cycle Boy, did you check either of these two threads? They don't specifically answer your question, but they may offer some insights. (Especially the bit at the end of the second one where a certain monk encouraged looking at the Notes documentation. :-)

Re: Lotus Notes
by buckaduck (Chaplain) on Apr 25, 2002 at 20:57 UTC
    As long as we're giving pointers to earlier Lotus examples, here's my own code sample. I learned most of what I needed to know from


Re: Lotus Notes
by Cycle Boy (Initiate) on Apr 26, 2002 at 08:20 UTC
    Thanks guys.

    I sussed it in the end so in case it helps anyone else here's how to create and save documents in a Lotus Notes database using Perl. I'm sure you can get more complicated than this but this works a treat for me.

    "test" is the name of the form, "plain_text", "SendTo" and "Report" are just some fields on the "test" form.

    (With the other code examples of sending notes and reading databases that you have kicking around on here I guess all usual bases are covered now.)

    use strict; use warnings; use diagnostics; use Win32::OLE; my $Notes = Win32::OLE->new('Notes.NotesSession')or die "$!: cannot st +art Lotus Notes Session object.\n"; my ($Version) = ($Notes->{NotesVersion} =~ /\s*(.*\S)\s*$/); print "The current user is $Notes->{UserName}.\n"; print "Running Notes \"$Version\" on \"$Notes->{Platform}\".\n"; my $Database = $Notes->GetDatabase('', 'h:\$config\notes\davidapitest. +nsf') or die "$!: could not open database.\n"; if ($Database->IsOpen) { print "database is open\n"; } else { print "database is not open\n"; } print "creating new document\n"; my $Document = $Database->CreateDocument('test') or die "$!: can't cre +ate document"; if ($Document->IsNewNote) { print "document is new not saved\n"; } else { print "document is not new\n"; } print "populating fields\n"; $Document->{'plain_text'} = 'buffy'; $Document->{'SendTo'} = 'the'; $Document->{'Report'} = 'vampire slayer'; print "saving document\n"; $Document->Save (1, 1); $Document->Close; if ($Document->IsNewNote) { print "document is new not saved\n"; } else { print "document is not new\n"; }

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://161897]
Approved by rob_au
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2024-04-15 02:53 GMT
Find Nodes?
    Voting Booth?

    No recent polls found