Link to home
Start Free TrialLog in
Avatar of shuping
shuping

asked on

invoke lotus notes application from VB

I want to invoke the lotos notes application and execute the lotus notes command to start a new message application.
I do not know how to link the lotus notes
Avatar of ghassan99
ghassan99

To link to Lotus Notes, u must use the Lotus Notes Automation Classes in VB.  When u create a Lotus Notes application in VB, u must reference notes32.tlb.  There is a very good free book in www.lotus.com/redbooks called 'Lotus Script for Visual Basic Programmers' It discusses this issue.  Basically what u can do to initialize a notes session is that:

Dim session As NOTESSESSION
Dim db As NOTESDATABASE
Dim view As NOTESVIEW
Dim doc As NOTESDOCUMENT

Set session = CreateObject("Notes.NotesSession")
Set db = session.GETDATABASE("", "test.nsf") 'name of ur application
Set view = db.GETVIEW("test") 'name of a view inside ur application
Set doc = view.GETFIRSTDOCUMENT 'gets the first doc in that view

All type of objects use the same properties and methods as in notes, u can check the object browser in VB to see all objects and their relevant methods and properties, and u can check the help in Notes. Its really simple and fun. u cant use the @commands of Notes in VB.

Avatar of shuping

ASKER

I got the error message from running the above recommended code.  message is " Database shuping han has not yet opened"
I tried to open my e-mail database which need password to open. would you please tell me how I can open this database.
By the way you mentioned that I cannot use the lotus notes @command in VB. would you please tell me how I can execute the lotus notes command after creating the object.

What I want to do is:

run VB programm to open lotus notes application new memo and attach the letter which is written in Word. With the recepient's name, address added automatically and default subject text is also added to subject field.
Avatar of shuping

ASKER

I got the error message from running the above recommended code.  message is " Database shuping han has not yet opened"
I tried to open my e-mail database which need password to open. would you please tell me how I can open this database.
By the way you mentioned that I cannot use the lotus notes @command in VB. would you please tell me how I can execute the lotus notes command after creating the object.

What I want to do is:

run VB programm to open lotus notes application new memo and attach the letter which is written in Word. With the recepient's name, address added automatically and default subject text is also added to subject field.
Avatar of shuping

ASKER

Hi,
Could anyone tell me how to use shell(), linktopic, linkitem, linkmode to link lotus notes application.

I want to do following:

by running a VB executable, user can open the lotus notes application new memo, passing the e-mail address from address book and attach word document to the new memo. subject field should get default value. All this should be done when user press a button on the VB form.


Shuping
Avatar of shuping

ASKER

The redbook you recommended is very helpful

Thank you
ASKER CERTIFIED SOLUTION
Avatar of ghassan99
ghassan99

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
u dont have to use DDE, its not advisable
Here is a simple code to do that:

Private Sub Command1_Click()

   Dim session As Object
   Dim db As Object
   Dim doc As Object
   Dim rtf As Object
   Dim nt As Object

   Set session = CreateObject("Notes.NotesSession")
   Set db = session.GETDATABASE("", "mail\gus.nsf")
   Set doc = db.CREATEDOCUMENT
   doc.Form = "Memo"
   doc.SendTo = "Paul Rony"
   doc.Subject = "New Memo"
   Set rtf = doc.CREATERICHTEXTITEM("Body")
   Call rtf.APPENDTEXT("Anything Goes!")
   Call rtf.ADDNEWLINE(2)
   Call rtf.EMBEDOBJECT(1454, "", "c:\loc.txt") 'use the same parameters except the filename
   Call doc.Send(False)
   Set doc = Nothing
   Set db = Nothing
   Set session = Nothing
End Sub


Avatar of shuping

ASKER

The last sample code you provide to me is helpful.
Thank you


Shuping
Avatar of shuping

ASKER

Hi ghassan99,
This simple sample code did work well. However, if I want to review/check before I send out the mail, I am unable to stop. I have tried to find the possiblitity. Unfortunately, I did not fine out.
Would you please give me some comments

Shuping
Private Sub Command1_Click()

   Dim session As Object
   Dim db As Object
   Dim doc As Object
   Dim rtf As Object
   Dim nt As Object

   Set session = CreateObject("Notes.NotesSession")
   Set db = session.GETDATABASE("", "mail\gus.nsf")
   Set doc = db.CREATEDOCUMENT
   doc.Form = "Memo"
   doc.SendTo = "Paul Rony"
   doc.Subject = "New Memo"
   Set rtf = doc.CREATERICHTEXTITEM("Body")
   Call rtf.APPENDTEXT("Anything Goes!")
   Call rtf.ADDNEWLINE(2)
   Call rtf.EMBEDOBJECT(1454, "", "c:\loc.txt") 'use the same parameters except the filename
   Call doc.Send(False)
   Set doc = Nothing
   Set db = Nothing
   Set session = Nothing
End Sub

What do u mean?
This function handles the sending:
Call doc.Send(False)
u can precede this with a msgbox to show u what will be sent...and if confirmed u can continue to the Call doc.Send(False)  else exit the sub
Avatar of shuping

ASKER

Hi ghassan99,

Thanks for your rapid responce and sharing your knoweldge with me. The question is that I want to see the "memo"'s send page  with the attached file ane then press send button instead of sending directly without notising anything. At that point the user can enter the recipient e-mail.

Thank you

Shuping
Create a form in VB and add text fields for recepients email and body field and just substitue those inside the formulas...like
  doc.SendTo = "Paul Rony"  becomes   doc.SendTo = txtRecepient.text
Then u can add a command button on the VB form which only sends the memo. name the command button 'Send' and put inside it the above code after u modify it.
Avatar of shuping

ASKER

Hi ghassan99,

Thanks very much for your quick response. What you suggested is not bad idea. I also considered the similar features as u recommended. However, I want the user to stop at the lotus notes new memo and select the recipients e-mail from lotus notes address database. Could you give me some suggestion.

Thank you very much

Shuping

Anyway, I think when u start this program in the first place Notes should be open...I suggest u remove the doc.send command and switch to Notes (while ur VB program is running) u will see it open with the new memo
Avatar of shuping

ASKER

Hi ghassan99,

If I remove the doc.send then the notes new memo never opened, even the notes login window can not prompt.


Shuping