views:

42

answers:

1

Hi,

I'm trying to figure out how to send an email using the Lotus Notes COM object provided in .NET. It seems easy, but I keep getting the error message "NSD Is Running". I'm testing the app on the machine that has lotus notes installed on it. Lotus notes does work on that machine. I close the Lotus note client on that machine, before I run my program.

Thank you, -Tesh

Here is my code:

New Code with that works:
Console.Write("-1")
    Dim lSession As Domino.NotesSession = New Domino.NotesSession()
    Dim lDB As Domino.NotesDatabase
    Dim lDoc As Domino.NotesDocument = Nothing
    Dim oItemValue As Object
    oItemValue = Nothing

    Dim user_password As String = ConfigurationManager.AppSettings("user_password")
    Dim inbox As String = ConfigurationManager.AppSettings("inbox")
    Dim server_name As String = ConfigurationManager.AppSettings("server_name")
    Dim pfile As String = ConfigurationManager.AppSettings("pfile")
    Dim fax_email As String = ConfigurationManager.AppSettings("fax_email")


    Console.Write("0")
    'ChDir("C:\lotus\notes\")

    Console.Write("1")
    lSession.Initialize(user_password)
    Console.Write("2")
    lDB = lSession.GetDatabase(server_name, pfile, False)
    Console.Write("3")

    If Not (lDB.IsOpen) Then
        lDB.Open()
    End If
    Console.Write("4")
    'lDoc = lDoc.CreateDocument()
    lDoc = lDB.CreateDocument()
    Console.Write("5")

    'Assign Field Values
    lDoc.ReplaceItemValue("Form", "Memo")
    lDoc.ReplaceItemValue("From", "[email protected]")
    lDoc.ReplaceItemValue("SendTo", fax_email)
    lDoc.ReplaceItemValue("Subject", "Test Fax Email")
    lDoc.ReplaceItemValue("Body", "Hello this is tesh doing test")
    lDoc.SaveMessageOnSend = True 'Ensure memo shows in sent folder
    lDoc.ReplaceItemValue("postDate", DateTime.Now.ToShortDateString())

    'Send requires an object for the recipients, so I give the send method the SendTo field as an object.
    oItemValue = lDoc.GetItemValue("SendTo")
    'Send the email
    lDoc.Send(False, oItemValue)
+1  A: 

I believe the line "lDoc = lDoc.CreateDocument() " should be "lDoc = lDb.CreateDocument() " - to create a new document object from an open Database object.

Ed Schembor
Thanks Ed, that fixed the "NSD is running" issue. The email went through. But I get a new message as I described above to Ken.
Hitesh Rana