I'm trying to send email via Lotus Notes.
This worked before I updated visual studio from 2003 to 2005. Now I get the following error message: "Attempted to read or write protected memory. This is often an indication that the memory is corrupt."
I understand that the .net Framework 2.0 has much stricter rules concerning untrusted components and I think the error comes from that, but I have no idea how to give the component a trusted status. I have a reference to Interop.Domino.
Below is my code:
DimdomSession As New NotesSession
Dim domNotesDBMailFile As NotesDatabase
Dim domNotesDocumentMemo As NotesDocument
Dim domNotesRichText As NotesRichTextItem
Dim strAttachment As String
Dim Username As String
Dim MsgResult As MsgBoxResult Username = Principal.WindowsIdentity.GetCurrent.Name Try
domSession.Initialize(txtPassword.text) 'Prompts user for Lotus Notes Password
domNotesDBMailFile = domSession.GetDatabase("", "names.nsf") 'This is where the error occurs
domNotesDocumentMemo = domNotesDBMailFile.CreateDocumentCall domNotesDocumentMemo.AppendItemValue("Form", "Memo") Call domNotesDocumentMemo.AppendItemValue("SendTo", domSession.CommonUserName) Call domNotesDocumentMemo.AppendItemValue("CopyTo", email@example.com) Call domNotesDocumentMemo.AppendItemValue("Subject", "Error - " & Username)
domNotesRichText = domNotesDocumentMemo.CreateRichTextItem("Body")
strAttachment ="C:\VBNet Projects\NetQT2\NetQT1\Data\ErrorLog.txt"
domNotesRichText.AppendText("NetQT error, sent " & Today.Date & Microsoft.VisualBasic.ControlChars.CrLf) Call domNotesRichText.EmbedObject(EMBED_TYPE.EMBED_ATTACHMENT, "", strAttachment, "")
MsgResult = MsgBox("The mail has been sent", MsgBoxStyle.OkOnly) If MsgResult = MsgBoxResult.Ok Then Me.Close() End If
Catch ex As exception
MsgBox("Email could not be sent! " & Err.Description)
Thanks for any help,
ChrisMonday, January 29, 2007 1:15 PM
Thanks for your reply. I don't believe this is a Lotus notes problem. Like I said in my message I could send mail with
this API before I updated to the .net Framwork 2.0. I think the new security levels that came with 2.0 are causing the error
due to the interop.domino being an untrusted component.
I need to know how to tell my application, that it is a trusted compoment.
ChrisTuesday, January 30, 2007 11:33 AM
You have to set the Lotes Notes client Server Name ...
also you have to set the boolean option as third option ....
domNotesDBMailFile = domSession.GetDatabase(ServerName, "names.nsf",False)'where ServerName is variable contains the LA client Server Name....Monday, May 21, 2007 11:24 AM