Hi,

I am trying to write a script that will take a name off the command line and return the internet email address as stored in the company global address book in Lotus Notes. The following script will loop through all records and print out the data, which I can redirect to a temp file for grep'ing later, but I would like to look it up realtime. I saw the @dblookup function in Lotus, but wasn't successful at running it via perl. Any ideas? Your help is greatly appreciated.

use strict;
use English;
use warnings;
use vars qw($opt_d $opt_v);
use Getopt::Std;
use Win32::OLE;

# Open the email database in Lotus Notes
# (To use another person's email database, switch to
#  their userid in Notes before running this program)
my $notes = Win32::OLE->new('Notes.NotesSession')
             or die "Can't open Lotus Notes";
my $database = $notes->GetDatabase("LNSERVER","names.nsf");
#my $database = $notes->GetDatabase("","names.nsf");

# Verify the server connection
print "Connected to ", $database->{Title}, 
      " on ", $database->{Server}, "\n";

# Loop over all of the folders
foreach my $viewname (GetViews($database)) {

  # Get the object for this View
  print "Checking folder $viewname...\n";
  my $view = $database->GetView($viewname);

  # Get the first document in the folder
  my $num = 1;
  my $doc = $view->GetFirstDocument;
  next unless $doc;
  GetInfo($num,  $doc);

  # Get the remaining documents in the folder
  while ($doc = $view->GetNextDocument($doc)) {
    $num++;
    GetInfo($num, $doc);
  }
}

sub GetInfo
{
  my ($num, $doc) = @_;

  my $FirstName = $doc->{'FirstName'}->[0];
  my $LastName = $doc->{'LastName'}->[0];
  my $MiddleInitial = $doc->{'MiddleInitial'}->[0];
  my $email = $doc->{'ShortName'}->[0];
  $email .= '@uhc.com';
  print "$FirstName $MiddleInitial $LastName\t$email\n";
}

sub GetViews {
   return ("People");
}

In reply to Re: Accessing a Lotus Notes Database by Anonymous Monk
in thread Accessing a Lotus Notes Database by scoombs

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.