OpenMailDatabase - 101

First time out with Lotus.It can’t get much easier, can it?

I can’t open the mail database

(not that I’m sure what to do with it

once I get it :-).

Output and code included.

What’s this rookie doing that’s wrong?

Lotus opens fine on my box; 6.5, XP

Thanks

---------------------------- output

The current user is CN=Hustque/OU=TMC/OU=AM/O=RAYO Inc.

Running Notes “Release 6.5|September 26, 2003” on “Windows/32”.

MAIL: BEGIN_OLE_MESSAGE

Win32::OLE(0.1603) error 0x80020003: “Member not found”

in METHOD/PROPERTYGET ""

END_OLE_MESSAGE

---------------------------- code

use strict;

use Win32::OLE qw( in );

my $oleMsg = ‘’;

my $Notes = Win32::OLE->new(‘Notes.NotesSession’)

or die “Cannot start Lotus Notes Session object.\n”;

my ($Version) = ($Notes->{NotesVersion} =~ /\s*(.\S)\s$/);

print qq/The current user is $Notes->{UserName}.\n/;

print qq/Running Notes “$Version” on “$Notes->{Platform}”.\n/;

NotesDatabase class

my $dir = $Notes->GetDbDirectory(“”);

$oleMsg = Win32::OLE->LastError();

if ($oleMsg) {

print qq(DIR: BEGIN_OLE_MESSAGE\n$oleMsg\nEND_OLE_MESSAGE\n);

}

my $m = $dir->OpenMailDatabase();

$oleMsg = Win32::OLE->LastError();

if ($oleMsg) {

print qq(MAIL: BEGIN_OLE_MESSAGE\n$oleMsg\nEND_OLE_MESSAGE\n);

}

Subject: OpenMailDatabase - 101

Can you give us some context about where you are calling your code from and what you are trying to do?

Subject: RE: OpenMailDatabase - 101

Target is to automate collection of my mail.The script will run on the box which has

the client distribution and the target mail

account. In fact the mail is already open.

Subject: RE: OpenMailDatabase - 101

Automate collection of your mail? Just create a local replica of your mail database and set a sufficiently short interval for scheduled replication. There is, to put it mildly, absolutely no reason to get all programmatic about this. See your Notes client Help database for more info.

Subject: RE: OpenMailDatabase - 101

Here’s a list of databases and folders(?) Iobtained from the Views attribute. Are any of

these the mail database, and how do you open

these?

my $Notes = Win32::OLE->new(‘Notes.NotesSession’);

my $db = $Notes->GetDatabase(‘’, ‘names.nsf’);

my $v = $db->{‘Views’};

foreach my $vn ( in $v) {

my $name = $vn->{‘Name’};

print qq/Name is $name\n/;

}

---- code is

Name is _Advanced\Connections

Name is Contacts

Name is Groups

Name is _Advanced\Certificates

Name is _Advanced\Locations

Name is By Category

Name is ($CompanyList)

Name is _Advanced\Accounts

Name is ($Accounts)

Name is _Advanced\International MIME Settings

Name is ($InternationalMIMESettings)

Name is ($ByCategory)

Name is Temporary Export Certificates

Name is ($Adminp)

Name is ($Certifiers)

Name is ($Connections)

Name is ($CrossCertByName)

Name is ($CrossCertByRoot)

Name is ($Groups)

Name is ($Locations)

Name is ($MailGroups)

Name is ($PeopleGroupsByLang)

Name is ($PeopleGroupsCorpHier)

Name is ($PeopleGroupsFlat)

Name is ($PeopleGroupsHier)

Name is ($People)

Name is ($ServerAccess)

Name is ($Users)

Name is ($VIMGroups)

Name is ($VIMPeopleAndGroups)

Name is ($VIMPeopleByLastName)

Name is ($VIMPeople)

Subject: RE: OpenMailDatabase - 101

What you have there is a list of views inside the public address book (Domino Directory). These are, essentially, indexed lists of documents in the Directory. None are databases, but they can lead you to databases the hard way, I suppose. If you were to grab one of the Person views (like ($VIMPeople)), you could cycle through the Person documents looking at the MailServer and MailFile fields on each to get the filepath to the mail database.

FWIW, OpenMailDatabase is used to open up the mail database for the current user (according to the id in use and the MailFile and MAilServer values in the notes.ini).

Subject: RE: OpenMailDatabase - 101

That’s a list of views and folders. Those are objects which are contained by databases. That is, what you’ve done is opened up a specific database (names.nsf) and gone through a list of views and folders. To get your mail database instead, substitute the file name for names.nsf.

But what I’d really recommend at this point is that you should stop programming right now. Notes is, to put it politely, weird. Powerful and useful, but weird, and jumping in with the COM/OLE documentation isn’t going to tell you enough about how Notes works to get stuff done without enormous frustration. Put the perl aside and read the Notes documentation in full, or perhaps get a book on Notes (I have a mercenary suggestion or two). I’m usually an advocate of learning by doing, but Notes is different enough from every other platform that doing a larger-than-usual amount of preliminary reading is likely to keep you from making a lot of rookie mistakes.

Subject: RE: OpenMailDatabase - 101

Ok, Lotus wins! I’ve made progress but timefor a book. Make some money. Go ahead…

suggest. :slight_smile:

Thanks.

PS There’s tons of lotus documentation.

Where would you start? Hacking thru

the objects is a board game with this

thing. And, I’ve always liked, no loved,

examples (java,c,perl,vb). Thanks again.

Subject: RE: OpenMailDatabase - 101

Lotus-brand documentation pretty much assumes that you know what Notes is, structurally. It is apparent that you do not. There’s no point trying to code against an object model if you haven’t a clue what those objects represent. (And, in another posting, I’ve pointed out that there’s no need to write anything to simply fetch your mail.)

If you want to program against Notes/Domino, I’d suggest starting with this:

The introductory section (by Richard Schwartz) is probably the best overview of what Notes and Domino are all about that you’ll ever run across. The remainder of the work will fill you in on programming for the platform. LotusScript is similar to VB6.

Subject: RE: OpenMailDatabase - 101

Well I finally did get it open and fooledaround with it BUT, agreed, book time.

Thanks for the suggestion.

Subject: Check your current Location, make sure you have the right Server and database defined.

Subject: RE: Check your current Location, make sure you have the right Server and database defined.

Isn’t that what printout did? It shows meand the lotus version. I’ll go browse objects

on ‘location’ and ‘current’ and such; otherwise

a terse one liner on how I might check this

would be appreciated.

GetDBDirecotry(“”) says: "Use an empty string

(“”) to indicate the current computer."

This is correct… right? I’ll try something

else.

Thanks

Subject: Do you have a Notes Client installed on your machine?

Subject: RE: Check your current Location, make sure you have the right Server and database defined.

Hummmm.

No matter how I define the string in

GetDBDirectory, I don’t get a failure.

Win32::OLE->LastError() is not

returning an error. I’ll have to see

if the Lotus model has an error object

that I can query.

Subject: RE: OpenMailDatabase - 101

The documentation for OpenMailDatabase (in the Domino Designer help) says: Note This method is supported in COM only.

You’re not using COM. Notes.NotesSession is the OLE set of classes. Use NotesDatabase.OpenMail instead.

Subject: RE: OpenMailDatabase - 101

I thought it one and the same so I asked.

OLE, OLE2, Com, COM+, DCOM and DNA are all part of the same technology.

The only real variances come when you’re trying to early bind (set a

reference which is what Perl’s COM library does), late bind (less

efficient, doesn’t load entire type library into memory at instantian),

proxied connections (not even sure if Perl leverages this).

I assume ole/com is at least a roughly

equivalent. In Lotus documentation is

there really a difference between ole/com?

Subject: RE: OpenMailDatabase - 101

The basic technology is the same, but that doesn’t mean that the programming interface for COM and OLE have to be identical, and for Notes they are not. Refer to this: Lotus Domino Designer 6.5 Help - COM-only properties and methods. There’s more on the subject in the same online database.