Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Close Notes

Status
Not open for further replies.

SpiderBear6

Programmer
Sep 17, 2003
422
0
0
AU
This is the VB.Net code I am using to automate the sending of an email through Lotus Notes.. we have all seen it before..

Dim notesdb As Object
Dim notesdoc As Object
Dim notesrtf As Object
Dim notessession As Object
Dim avarrecip(1) As Object
'Dim avarattach(1) As Object

Dim bSuccess As Boolean = True

Try

'make new mail message

Try
notessession = GetObject(, "Notes.Notessession")
Catch ex As Exception
notessession = CreateObject("Notes.Notessession")

End Try


notesdb = notessession.GetDatabase("", "rwebser.nsf")

' notessession.Initialize("password")

If Not notesdb.ISOPEN Then notesdb.OPENMAIL()

notesdoc = notesdb.CREATEDOCUMENT
Call notesdoc.ReplaceItemValue("Subject", sSubject)
notesrtf = notesdoc.CreateRichTextItem("body")
Call notesrtf.AppendText(sMessage)
Call notesrtf.AddNewLine(2)

' Call notesrtf.EmbedObject(1454, "", avarattach(0), "Attachment")
' Call notesrtf.EmbedObject(1454, "", avarattach(1), "Attachment")

'send message
avarrecip(0) = sTo
Call notesdoc.Send(False, avarrecip)

Catch ex As Exception
bSuccess = False
Finally
notesdoc = Nothing
notesrtf = Nothing
notesdb = Nothing
notessession = Nothing
End Try

Return bSuccess

My problem is that this code leaves the state of Lotus Notes in a mess. When I run this code again everything works fine, but if I try to open up Notes manually, I get an error "An error was encountered while opening a window" which seems to be because the nlnotes.exe process is still in memory. There is no close on notessession that I can tell and I have tried GC.Collect but that does't work. So how do you clean up a notes object?

[sadeyes]
 
You could use the LotusScript/com classes to automate the email without having to open up the notes client.

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]
 
As in the Domino objects... yep...decided to do it that way.. works better.. thanks dwarfthrower.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top