Hi All!
I have a problem with Lotus Notes which I cannot solve for a long time although searching and serching a lot in the web.
I receive mails through LN and loop through a certain folder, reading DeliveredDate, Body, Subject and writing those items into an Access-table.
This works fine, before I go for the loop I put the doc in another folder and remove the current doc from the folder.
Call LNDoc.PutInFolder("SMSBackup", False)
Call LNDoc.RemoveFromFolder("SMSResponse")
Set LNDoc = LNView.GetNextDocument(LNDoc)
Loop
Without any error, without anything abnormal in the mails the code exits after a few loops, sometime after more or sometime after less read mails.
The problem ist the RemoveFromFolder, not the PutInFolder function.
So to avoid this behavoir, I changed my code to finish the loop without
Call LNDoc.PutInFolder("SMSBackup", False)
Call LNDoc.RemoveFromFolder("SMSResponse")
and added after the loop a NotesCollection which should do ALL at once.
But this part of the code does nothing at all (allthough found on the web).
With LNCollection
.PutAllInFolder "SMSBackup", False
.RemoveAllFromFolder "SMSResponse"
End With
The complete code looks like this:
***************************
Set objNotes = GetObject("", "Notes.NotesSession")
Set LNdb = objNotes.GetDatabase("myServer", "MyNSF")
If Not LNdb.IsOpen Then LNdb.OpenDatabase
If Not (LNdb Is Nothing) Then
Set LNView = LNdb.GetView("SMSResponse")
Set LNCollection = LNdb.Search("", Nothing, 0)
If Not (LNView Is Nothing) Then
Call LNView.Refresh
Set rs = CurrentDb.OpenRecordset("tmpReadMails")
Set LNDoc = LNView.GetFirstDocument
Do While Not LNDoc Is Nothing
Set LNItemDatum = LNDoc.GetFirstItem("DeliveredDate")
Set LNItemAbsender = LNDoc.GetFirstItem("From")
Set LNItemVeranstaltungsnummer = LNDoc.GetFirstItem("Subject")
Set LNItemVeranstaltungsText = LNDoc.GetFirstItem("Body")
rs.AddNew
......
rs.Update
Call LNDoc.PutInFolder("SMSBackup", False)
' works, but take not all Mails!
Call LNDoc.RemoveFromFolder("SMSResponse")
Set LNDoc = LNView.GetNextDocument(LNDoc)
Loop
End If
'alternativeley, but does not work at all
With LNCollection
.PutAllInFolder "SMSBackup", False
.RemoveAllFromFolder "SMSResponse"
End With
**********
I hope that someone can help with this annoying Notes matter.
Thanks a lot
Michael
I have a problem with Lotus Notes which I cannot solve for a long time although searching and serching a lot in the web.
I receive mails through LN and loop through a certain folder, reading DeliveredDate, Body, Subject and writing those items into an Access-table.
This works fine, before I go for the loop I put the doc in another folder and remove the current doc from the folder.
Call LNDoc.PutInFolder("SMSBackup", False)
Call LNDoc.RemoveFromFolder("SMSResponse")
Set LNDoc = LNView.GetNextDocument(LNDoc)
Loop
Without any error, without anything abnormal in the mails the code exits after a few loops, sometime after more or sometime after less read mails.
The problem ist the RemoveFromFolder, not the PutInFolder function.
So to avoid this behavoir, I changed my code to finish the loop without
Call LNDoc.PutInFolder("SMSBackup", False)
Call LNDoc.RemoveFromFolder("SMSResponse")
and added after the loop a NotesCollection which should do ALL at once.
But this part of the code does nothing at all (allthough found on the web).
With LNCollection
.PutAllInFolder "SMSBackup", False
.RemoveAllFromFolder "SMSResponse"
End With
The complete code looks like this:
***************************
Set objNotes = GetObject("", "Notes.NotesSession")
Set LNdb = objNotes.GetDatabase("myServer", "MyNSF")
If Not LNdb.IsOpen Then LNdb.OpenDatabase
If Not (LNdb Is Nothing) Then
Set LNView = LNdb.GetView("SMSResponse")
Set LNCollection = LNdb.Search("", Nothing, 0)
If Not (LNView Is Nothing) Then
Call LNView.Refresh
Set rs = CurrentDb.OpenRecordset("tmpReadMails")
Set LNDoc = LNView.GetFirstDocument
Do While Not LNDoc Is Nothing
Set LNItemDatum = LNDoc.GetFirstItem("DeliveredDate")
Set LNItemAbsender = LNDoc.GetFirstItem("From")
Set LNItemVeranstaltungsnummer = LNDoc.GetFirstItem("Subject")
Set LNItemVeranstaltungsText = LNDoc.GetFirstItem("Body")
rs.AddNew
......
rs.Update
Call LNDoc.PutInFolder("SMSBackup", False)
' works, but take not all Mails!
Call LNDoc.RemoveFromFolder("SMSResponse")
Set LNDoc = LNView.GetNextDocument(LNDoc)
Loop
End If
'alternativeley, but does not work at all
With LNCollection
.PutAllInFolder "SMSBackup", False
.RemoveAllFromFolder "SMSResponse"
End With
**********
I hope that someone can help with this annoying Notes matter.
Thanks a lot
Michael