VB2005: Email interop works in Notes 6.0.2, but not 6.0.4

I am writing a VB2005 application that will automatically generate emails and display them to the end user (eventually, these will have reports attached to them). Here’s my code:

'######### BEGIN CODE ############

Private Sub BuildLotusNotesObject()

Dim nSession As New NotesSession

Dim nDatabase As NotesDatabase

Dim nDocument As NotesDocument

Dim nRTItem As NotesRichTextItem



If Not (nSession Is Nothing) Then

  'start a new notes session

  nSession.Initialize()



  'get the database based on the current user info

  Dim server As String = nSession.GetEnvironmentString("MailServer", True) 'Get user's home/mail server

  Dim mailfile As String = nSession.GetEnvironmentString("MailFile", True) 'Get user's mail file name

  nDatabase = nSession.GetDatabase(server, mailfile, False)



  'proceed only if the previous GetDatabase call worked

  If Not (nDatabase Is Nothing) Then



    'generate a notes Memo to send as an email

    nDocument = nDatabase.CreateDocument()

    nDocument.ReplaceItemValue("Form", "Memo")

    nDocument.ReplaceItemValue("SendTo", Me.MailTo)

    nDocument.ReplaceItemValue("CopyTo", Me.m_mailCC)

    nDocument.ReplaceItemValue("BlindCopyTo", Me.m_mailBCC)

    nDocument.ReplaceItemValue("Subject", Me.MailSubject)



    'Create the message body

    nRTItem = nDocument.CreateRichTextItem("Body")



    'append the user supplied text

    nRTItem.AppendText(Me.MailBody)



    'display the email

    nDocument.Save(True, False)

    Process.Start(nDocument.NotesURL)

    

  Else

    'GetDatabase call failed

    Throw New Exception("Could not retrieve notes database")

  End If



End If



nSession = Nothing

nDatabase = Nothing

nDocument = Nothing

nRTItem = Nothing

End Sub

'######### END CODE ############

This code works fine on notes 6.0.2 for me and for the customer. The customer has multiple versions of Notes 6.X running in their facility though. On 6.0.4, the process fails for both of us. the line:

    'append the user supplied text

    nRTItem.AppendText(Me.MailBody)

is throwing a System.AccessViolationException. The exception message says “Attempted to read or write protected memory. This is often an indication that other memory is corrupt.” Any ideas what i would need to do to fix this? Again, it works fine in 6.0.2 :-\

Subject: VB2005: Email interop works in Notes 6.0.2, but not 6.0.4

bump :frowning:

Subject: VB2005: Email interop works in Notes 6.0.2, but not 6.0.4

I’m having a similar problem with almost identical code; except that, in my application, I get the error when the user has a multi-user install. For single users it works fine.

Most frustrating.

Subject: RE: VB2005: Email interop works in Notes 6.0.2, but not 6.0.4

Well, i found a way to make mine work. It was pure luck, but i changed Dim nRTItem As NotesRichTextItem

to

Dim nRTItem As Object

and now its happy. I cant stand Lotus Interop. I only figured this much out as I said, by pure luck. Its sad that business rely on this $#%^…

<---- never been so frustrated with fixing a problem due to the method of resolution

Subject: RE: VB2005: Email interop works in Notes 6.0.2, but not 6.0.4

My guess is that the error message we both received is simply the generic error message that one always receives when one is trying to interact with Lotus Notes (6.5.2 in my case) and there is a problem.I made the same change that you made but it made no difference in my case.

Oh, and yes, I also am quite frustrated. Hopefully others will add to the discussion.

Subject: RE: VB2005: Email interop works in Notes 6.0.2, but not 6.0.4

Frustrated is right! The API was written by Scott Devendorf, and he’s got several blogs out there - I am going to try him on this “Attempted to read or write protected memory” error and see what he has to say. I’ll let you know what I hear back.

Subject: RE: VB2005: Email interop works in Notes 6.0.2, but not 6.0.4

I am gettign the same issue with a 6.0 client although it worked on my 7.0 client. I am upgrading the user to 7.0 today and will see if it fixes it.

Did anyone find anything else out?

Subject: RE: VB2005: Email interop works in Notes 6.0.2, but not 6.0.4

I upgraded the client to 7.02 and it works now. Must be an issue with 6.

Subject: RE: VB2005: Email interop works in Notes 6.0.2, but not 6.0.4

A while has passed and I did an update to the program I wrote. Suddenly I started getting this error again. After a lot of searching, I found some threads about the nlsxbe.dll not getting registered properly in Notes 6. Even tho I was using 7.02, I tried it and the problem stopped.

You might try to register this DLL and see if your problem goes away.