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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

vb.net call to Lotus Notes crashing

Status
Not open for further replies.

evaleah

Programmer
Mar 18, 2003
252
US
I have a vb.net app that calls Notes in the background (the client never opens) and executes the following:
Code:
Public Function ReadMail(ByVal MessageUniversalID As String, ByVal MailFolder As String) As String()
Dim EmailData(4) As String 'string data to return
Dim oNotesSession As New NotesSession
Dim oNotesDatabase As NotesDatabase
Dim oNotesDocument As NotesDocument
Dim sPassword As String = NotesPW 'Password used by COM to pass to the Notes client login.

Try
'create a notes session object
oNotesSession.Initialize(sPassword) 'Initialise session by passing a password. Lotus Notes will not load.

'Create a database handle to the database you wish to send the mail message from.
oNotesDatabase = oNotesSession.GetDatabase(NotesDB, NotesInbox, False)
'If the database is not already open then open it.
If Not oNotesDatabase.IsOpen Then
oNotesDatabase.Open()
End If

'retreive specific document
oNotesDocument = oNotesDatabase.GetDocumentByUNID(MessageUniversalID)
With oNotesDocument
EmailData(0) = .UniversalID.ToString
EmailData(1) = .GetItemValue("From")(0)
EmailData(2) = .GetItemValue("Subject")(0)
EmailData(3) = .GetItemValue("Body")(0)
EmailData(4) = .GetItemValue("DeliveredDate")(0)
End With
Catch ex As Exception
Console.WriteLine("{0} My Exception caught.", ex)
Finally
oNotesSession = Nothing
oNotesDatabase = Nothing
oNotesDocument = Nothing
End Try

Return EmailData
End Function

Public Sub MoveMail(ByVal MessageUniversalID As String, ByVal SourceFolder As String, ByVal DestinationFolder As String)
Dim oNotesSession As New NotesSession
Dim oNotesDatabase As NotesDatabase
Dim oNotesDocument As NotesDocument
Dim sPassword As String = NotesPW 'Password used by COM to pass to the Notes client login.

Try
'create a notes session object
oNotesSession.Initialize(sPassword) 'Initialise session by passing a password. Lotus Notes will not load.

'Create a database handle to the database you wish to send the mail message from.
oNotesDatabase = oNotesSession.GetDatabase(NotesDB, NotesInbox, False)
'If the database is not already open then open it.
If Not oNotesDatabase.IsOpen Then
oNotesDatabase.Open()
End If

'retreive specific document
oNotesDocument = oNotesDatabase.GetDocumentByUNID(MessageUniversalID)
With oNotesDocument
.PutInFolder(DestinationFolder)
.RemoveFromFolder(SourceFolder)
End With
Catch ex As Exception
Console.WriteLine("{0} My Exception caught.", ex)
Finally
oNotesSession = Nothing
oNotesDatabase = Nothing
oNotesDocument = Nothing
End Try
End Sub
After running those scripts a window pops up saying Lotus Notes has experienced an error and is logging it. Afterward I check the log and here is the error:
Code:
06/03/2010 10:40:37 AM Lotus Notes client started
06/03/2010 10:40:40 AM Client Execution Security is enabled.
06/03/2010 10:41:06 AM Dynamic Client Configuration started
06/03/2010 10:41:06 AM Initializing Dynamic Client Configuration
06/03/2010 10:41:06 AM Dynamic Client Configuration updating policy information
06/03/2010 10:41:06 AM Dynamic Client Configuration: Returned an error adding policy information to the address book: Note item not found
06/03/2010 10:41:06 AM Dynamic Client Configuration: Applying policy bookmarks
06/03/2010 10:41:06 AM Dynamic Client Configuration updating location information
06/03/2010 10:41:06 AM Dynamic Client Configuration updating location information using policy
06/03/2010 10:41:06 AM Dynamic Client Configuration updating location information using policy
06/03/2010 10:41:06 AM Dynamic Client Configuration updating location information using policy
06/03/2010 10:41:06 AM Dynamic Client Configuration updating location information using policy
06/03/2010 10:41:06 AM Dynamic Client Configuration updating location information using policy
06/03/2010 10:41:06 AM Dynamic Client Configuration updating location information using policy
06/03/2010 10:41:06 AM Dynamic Client Configuration shutdown
I don't have a clue where to go with this and am completely lost. Anyone with any suggestion of where to look, what to try, I would be so grateful! If you need more information, let me know as well. I wasn't even sure where to start with that.

Thanks,
Eva
 
Turns out the crash is occurring after I apparently have set the object containing the Notes references to nothing and when I call an object to connect to an Access database. It is when I make the Oledb call to execute a query that the crash occurs. Not actually in any of the code I listed above. Does anyone have any idea what I am leaving open that would make Notes think it needed to do anything with this?
Code:
Private Sub EnterNewEmailsintoLogTable(ByVal strFolder As String)
        Dim objNM As New NotesMail
        Dim strEmailData(4) As String
        Dim intCount As Integer = 1

        Dim arrUID() As String = objNM.GetMessageIDsFromFolder(strFolder)
        Dim strSQL(arrUID.Length - 1) As String

        'if there were no emails in the folder arrUNID will return with only empty strings
        'check that the first string has a value, otherwise, skip.  There is nothing to process.

        If Not arrUID(0) Is Nothing Then
            intCount = 0
            For Each S As String In arrUID
                strSQL(intCount) = "insert into tblRegister_ProcessLog (UNID, [From], Subject, Body, DeliveredDate) values ("
                strEmailData = objNM.ReadMail(S, strFolder)
                strSQL(intCount) += """" + strEmailData(0) + """, "
                strSQL(intCount) += """" + strEmailData(1) + """, "
                strSQL(intCount) += """" + strEmailData(2) + """, "
                strSQL(intCount) += """" + strEmailData(3) + """, "
                strSQL(intCount) += """" + strEmailData(4) + """) "

                'move file to processed folder and remove from receipt folder
                objNM.MoveMail(S, "Registration", "Registration\Archive")
                intCount = intCount + 1
            Next

            objNM = Nothing

            Do While intCount >= 0
                'insert into log table
            'NOTES ERROR OCCURS ON THIS LINE BELOW!!!!!!
                objPID.ExecuteText(strSQL(intCount))
                intCount = intCount - 1
            Loop
        End If

    End Sub
I am open to ANY suggestion at all. I have not a clue why Notes is reacting to something that shouldn't be about Notes. The class in question doesn't even have a reference to the Domino object!
 
SOLVED! I am sharing in case anyone else runs into this and finds this thread.

Turns out I had to just call the objects in two different subroutines. I couldn't instantiate the objects together. Then it works. Go figure.....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top