SpiderBear6
Programmer
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] [sadeyes] [sadeyes]](/data/assets/smilies/sadeyes.gif)
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] [sadeyes] [sadeyes]](/data/assets/smilies/sadeyes.gif)