http://www.perlmonks.org?node_id=162219


in reply to Lotus Notes

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"; }