Question : Lotus notes cannot auto-reply emails that are sent by this code

I have created a simple auto-reply action agent in account B.
But when I use account A to send email to account B using the attached codes, no auto-reply to account A.


Any help is appreciated. Thanks~
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
Public Sub sendNotes()
 
 
        Dim recep As String() = ssMailTo
        Dim ccRecipient As String() = New String() {}
        Dim subj As String = sSubjectSend
        Dim mailbody As String = "" '"hi" + ControlChars.NewLine + "bye"
 
        Dim savemsg As Boolean
 
        open()
 
        Dim domNotesDocumentMemo As NOTESDOCUMENT
        Dim DomNotesItem As NOTESITEM
        Dim sUser As String
        Dim objNotesRichTextItem As NOTESRICHTEXTITEM
 
 
        ' Create a new memo document.
        domNotesDocumentMemo = domDB.CreateDocument
        'Call domNotesDocumentMemo.AppendItemValue("Form", "Memo")
        'Call domNotesDocumentMemo.AppendItemValue("Form", "Mail")
        Call domNotesDocumentMemo.AppendItemValue("From", domS.CommonUserName)
 
 
        Call domNotesDocumentMemo.AppendItemValue("SendTo", "")
        'Now get a handle on the item
        DomNotesItem = domNotesDocumentMemo.GetFirstItem("SendTo")
        'Now pass your array
        For Each r As String In recep
            If r <> "" Then
                Call DomNotesItem.AppendToTextList(r)
            End If
        Next
 
        'create or instantiate the item
        Call domNotesDocumentMemo.AppendItemValue("CopyTo", "")
        'Now get a handle on the item
        DomNotesItem = domNotesDocumentMemo.GetFirstItem("CopyTo")
        'Now pass your array
        For Each s As String In ccRecipient
            If s <> "" Then
                Call DomNotesItem.AppendToTextList(s)
            End If
        Next
 
        Call domNotesDocumentMemo.AppendItemValue("Subject", subj)
        objNotesRichTextItem = domNotesDocumentMemo.CreateRichTextItem("Body")
        Call objNotesRichTextItem.AppendText(mailbody)
 
        If Trim(LCase(savemsg)) = "yes" Then
            domNotesDocumentMemo.SaveMessageOnSend = True
        Else
            domNotesDocumentMemo.SaveMessageOnSend = False
        End If
        domNotesDocumentMemo.Send(False)
        domNotesDocumentMemo = Nothing
 
        close()
 
    End Sub
 
 
    Function open() As Boolean
 
        IO.File.Copy(IO.Path.Combine(IO.Directory.GetCurrentDirectory, sIDfilePath), IO.Path.Combine(notesDataPath, sIDfilePath), True)
        IO.File.Copy(IO.Path.Combine(IO.Directory.GetCurrentDirectory, "notes.ini"), IO.Path.Combine(notesPath, "notes.ini"), True)
        WritePrivateProfileString("Notes", "KeyFilename", IO.Path.Combine(notesDataPath, sIDfilePath), IO.Path.Combine(notesPath, "notes.ini"))
        WritePrivateProfileString("Notes", "MailFile", sPfile, IO.Path.Combine(notesPath, "notes.ini"))
 
        domS = New NOTESSESSION
        'domS = CreateObject("lotus.NotesSession")
        'domS = GetObject("", "Notes.Notesession")
        
 
        Call domS.Initialize(sPpassword)
        'System.Threading.Thread.Sleep(2000)
        domDB = domS.GetDatabase(sPserver, sPfile)
        'System.Threading.Thread.Sleep(2000)
 
 
        Return True
 
    End Function
 
    Sub close()
 
        domDB = Nothing
        domS = Nothing
 
        GC.Collect()
        GC.WaitForPendingFinalizers()
 
    End Sub

Answer : Lotus notes cannot auto-reply emails that are sent by this code

The very first problem seems to be that the session is not being created.

Your code has a few statements, with two remarked out...

   domS = New NOTESSESSION
   'domS = CreateObject("lotus.NotesSession")
   'domS = GetObject("", "Notes.Notesession")

I would expect this to be
    Set domS = CreateObject("Notes.Notessession")

Also, some of the initial work is being done within the Open sub, however I assume the variables are being declared somewhere else, and are global.  For example domS should be declared as

      Dim domS as Object

but more importantly it needs to be global otherwise it's context will be lost after execution of the Open() sub is complete.


Random Solutions  
 
programming4us programming4us