I seem to be getting the same "'451 Property let procedure not defined and property get procedure did not return an object" run time error when trying to get the subject of my emails from Lotus Notes. I have tried by using both GetFirstItem("subject")
as well as ColumnValues(5)
but both drop the same error.
The below is the GetFirstItem
method, NSubject
in this case does hold the variable Values(0) with the subject line captured correctly. I just can't seem to figure out how to pull it and use it.
Sub Test_subject()
Dim NSession As Object
Dim NMailDb As Object
Dim NFolder As Object
Dim NView As Object
Dim NDocument As Object
Dim NSubject As Object
Dim NItem As Variant
Set NSession = CreateObject("Lotus.NotesSession")
Call NSession.Initialize("password")
Set NMailDb = NSession.GetDatabase("Server", "Directory")
If Not NMailDb.IsOpen = True Then
Call NMailDb.Open
End If
Set NFolder = NMailDb.GetView("($Inbox)")
Set NView = NFolder.CreateViewNav()
Set NDocument = NView.GetLastDocument
Set NItem = NDocument.Document
Set NSubject = NItem.GetFirstItem("subject")
MsgBox (NSubject.Values(0))
End Sub
Changing to .ColumnValues(6)
which contains the correct value also drops the same error. I'm clearly not understanding something but I'm not sure where I'm going wrong.
Set NDocument = NView.GetLastDocument
NItem = NDocument.ColumnValues(6)
CodePudding user response:
Replacing .GetFirstItem("subject")
with .GetItemValue("Subject")
works fine for this. I would like to know however why the above doesn't work because I feel like pulling .ColumnValues
may be useful in the future.
CodePudding user response:
It's complaining about this line:
Set NItem = NDocument.Document
You had previously assigned Set NDocument = NView.GetLastDocument
, so NDocument is an object in the NotesDocument class. NDocument.Document
throws an error because there is no Document property in the NotesDocument class.
This line of code is pointless, anyhow. You already have your NotesDocument object. And it's kind of weird to try to assign a NotesDocument object to a variable named NItem. You should be using an object variable named NItem only if you are using the GetFirstItem method.
Your next line of code needs to be:
Set NSubject = NDocument.GetFirstItem("subject")
instead of
Set NSubject = NItem.GetFirstItem("subject")
And if you want to use ColumnValues, it will be NDocument.ColumnValues
, not NItem.ColumnValues
.