Starting Lotus Notes

laetitia

New member
Joined
Sep 20, 2005
Messages
3
Programming Experience
Beginner
The following code starts Lotus Notes, create a new memo and then display the new email in Lotus Notes. However it needs to be written so it compiles when Option Strict is on.

Dim session as Object
Dim db as Object
Dim domDoc as Object
Dim ws as Object

session= CreateObject("Notes.NotesSession")
db = session.GetDatabase("", "mailfile.nsf")

db.OpenMail()

domDoc = db.CreateDocument

CallByName(domDoc, "Form", CallType.Set, "Memo")

CallByName(domDoc, "SendTo", CallType.Set, "email address")

ws = CreateObject("Notes.NotesUIWorkspace")

ws.EditDocument("True", domDoc)

If I add a reference to the Domino class and do

Dim session as Domino.NotesSession
session = CType(CreateObject("Notes.NotesSession"), Domino.NotesSession)

I get an error saying specified cast is not valid. Please help


 
Thanks for replying kulrom.
If I do dim session as New Domino.NotesSession, it does not start Lotus Notes. What I am trying to do is start Lotus Notes and open the user's inbox which I know how to do using CreateObject and the GetDatabase and OpenMail methods but I do not know how to do it when option strict is on.

Regards
Laetitia
 
I wanted to use session=CreateObject("Notes.NotesSession") and be able to compile the code with option strict on. If I use the Domino class I do not have access to the NotesUIWorkspace class, which is needed to display the new memo (I think).
However I found the class CallByName in .NET, which solved my problem.
So with option strict off, I could write

<code>
Dim NotesSession as Object
NotesSession = CreateObject("Notes.NotesSession")




NotesSession.GetDatabase("",m_UserMailfile)





</code>

But with option strict on the second line would not compile. This was replaced by

<code>
Dim ParametersGetDb() As String = {"", m_UserMailFile}





NotesDb = CallByName(NotesSession, "GetDatabase", CallType.Method, ParametersGetDb)

</code>

I don't know if it is very elegant but it seems to work. I have enclosed the rest of the code.

<code>




Dim Addresses As New StringBuilder

Dim i As Integer

Dim NotesSession As Object

Dim NotesDb As Object

Dim NotesDoc As Object

Dim NotesWorkspace As Object

Dim ParametersGetDb() As String = {"", m_UserMailFile}

Dim ParametersEditDoc() As Object = {"True", ""}

'get the email addresses

For i = 1 To Recipient.Count

Addresses.Append(Recipient.Item(i))

Addresses.Append(",")

Next

'start a new Notes Session

NotesSession = CreateObject("Notes.NotesSession")

'get the user notes database



NotesDb = CallByName(NotesSession, "GetDatabase", CallType.Method, ParametersGetDb)

'open user mail database



CallByName(NotesDb, "OpenMail", CallType.Method)

'create new document

NotesDoc = CallByName(NotesDb, "CreateDocument", CallType.Method)



'set some parameters

CallByName(NotesDoc, "Form", CallType.Set, "Memo")

CallByName(NotesDoc, "SendTo", CallType.Set, Addresses.ToString)

ParametersEditDoc.SetValue(NotesDoc, 1)

'create a NotesUIWorkspace

NotesWorkspace = CreateObject("Notes.NotesUIWorkspace")

'open the new memo previously created



CallByName(NotesWorkspace, "EditDocument", CallType.Method, ParametersEditDoc)

</code>


 
Back
Top