Link to home
Start Free TrialLog in
Avatar of rmichels
rmichels

asked on

Access Notes Object from VB

I want to send a notes mail, under control of VB.  I have connected to the notes object and tried the following code:

Dim session As Object
Dim db As Object
Dim doc As Object
Dim s As String


Set session = CreateObject("Notes.NotesSession")

Set db = session.CURRENTDATABASE
Set doc = db.CREATEDOCUMENT
doc.Form = "Memo"
doc.SendTo = "Raymond J Michels/BALT/BDX"
doc.Subject = "Here's the document you wanted"
Call doc.SEND(False)

Session is valid, because I can access a value like NotesVersion.  But the session.CurrentDatabase is returning Nothing, not setting the db variable.

At one point this started working, but it mostly fails:

1) Why?
2) Is there any web based document on accessing the notes object (better than what comes in notes help).

Thanks
ASKER CERTIFIED SOLUTION
Avatar of dalehend
dalehend

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rmichels
rmichels

ASKER

I'm not sure this answers my question (without looking at the lSX toolkit).

In my example, the db object is Nothing, so I can't access it to do the OpenMail method.

Comments?
That function db.openmail sets the db to the default mail database(I think it gets it from NOTES.INI), so it does not matter if db is set to NOTHING.
Trying to do this in VB, db must be something, not nothing.  VB will display an error if you try to use the a method on an object that is nothing.
I should have posted more of the routine from the example:
Private Sub Form_Load()
's and db declared in general as object
Set s = CreateObject("Notes.Notessession")  'create notes session
Set db = s.getdatabase("", "")       'set db to database not yet named
Call db.openmail       'set database to default mail database


I hope this makes it more clear for you how to set db.
Thanks.  It works now :)