ich hab in meiner Codeschnipsel-Sammlung das hier gefunden, habs allerdings nie ausprobiert :
The NotesUnreadMarks represents a subset of all the documents in a database.
The documents in the subset are determined by which documents are unread by the user at the time a new instance is created.
Creates a NotesUnreadMarks object that represents the unread documents for a specific user in a specific replica of a database database located at the server and file name you specify.
Syntax
Dim variableName As New NotesUnreadMarks( notesDatabase, username$ )
or
Set notesunreadmarks = New NotesUnreadMarks( notesDatabase, username$ )
If the user name is hierarchical, the username parameter must be passed in the canonical format. eg. CN=First Name/OU=Office/O=Company/C=Country
Example
Dim sess As New NotesSession
Dim db As NotesDatabase
Dim urm As NotesUnReadMarks
Dim doc As NotesDocument
Dim msgbody As String
Set db = sess.CurrentDatabase
Set urm = New NotesUnreadMarks(db,sess.UserName)
Set doc = urm.GetFirstDocument
msgbody = "Server: " + urm.Server + Chr(13)
msgbody = Msgbody + "Filepath: " + urm.FilePath + Chr(13)
msgbody = Msgbody + "Username: " + urm.Username + Chr(13) + Chr(13)
msgbody = Msgbody + "Here are the unread marks from first to last." + Chr(13) + Chr(13)
While Not doc Is Nothing
msgbody = msgbody + doc.Subject(0) + Chr(13)
Set doc = urm.GetNextDocument(doc)
Wend
Messagebox msgbody,0,"Unread Documents"
Code: 'Paste into the Declarations section of your Script.
'
' NotesUnreadMarks class (R1.0)
' Written by: Daniel Alvers (daniel.alvers@au.pwcglobal.com)
' PricewaterhouseCoopers (Aust)
' February, 7 2000
'
' This code is provided as is and no warranty, express or implied, exists as to its fitness for use for any purpose.
' You are free to use and distributed the code as long as credit is retained and this header is not removed
'
Declare Function W32_SECKFMGetUserName Lib "nnotes.dll" Alias "SECKFMGetUserName" ( Byval UserName As String) As Integer
Declare Function W32_NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" ( Byval dbName As String, hDb As Long) As Integer
Declare Function W32_IDScan Lib "nnotes.dll" Alias "IDScan" ( Byval hUnreadTable As Integer, Byval First As Integer, NoteID As Long) As Integer
Declare Function W32_NSFDbGetUnreadNoteTable Lib "nnotes.dll" Alias "NSFDbGetUnreadNoteTable" (Byval hDb As Long, Byval UserName As String, Byval NameLength As Integer, Byval Create As Integer, hUnreadTable As Integer) As Integer
Declare Function W32_NSFDbUpdateUnread Lib "nnotes.dll" Alias "NSFDbUpdateUnread" ( Byval hDb As Long, Byval hTable As Integer) As Integer
Declare Function W32_NSFDbClose Lib "nnotes.dll" Alias "NSFDbClose" ( Byval hDb As Long) As Integer
Declare Function W32_IDDestroyTable Lib "nnotes.dll" Alias "IDDestroyTable" ( Byval hTable As Integer) As Integer
Declare Function W32_IDInsert Lib "nnotes.dll" Alias "IDInsert" ( Byval hTable As Integer, Byval NoteID As Long, retInserted As Integer) As Integer
Declare Function W32_IDDelete Lib "nnotes.dll" Alias "IDDelete" ( Byval hTable As Integer, Byval NoteID As Long, retDeleted As Integer) As Integer
Declare Function W32_IDIsPresent Lib "nnotes.dll" Alias "IDIsPresent" (Byval hTable As Integer, Byval NoteID As Long) As Integer
Declare Function W32_IDTableCopy Lib "nnotes.dll" Alias "IDTableCopy" ( Byval hOriginalTable As Integer, hNewCopy As Integer) As Integer
Declare Function W32_NSFDbSetUnreadNoteTable Lib "nnotes.dll" Alias "NSFDbSetUnreadNoteTable" ( Byval hDb As Long, Byval UserName As String, Byval NameLength As Integer, Byval Flush As Integer, Byval hOriginalTable As Integer, Byval hUnreadTable As Integer) As Integer
Type NoteIndex
PrevNoteID As Long
NoteID As Long
NextNoteID As Long
End Type
Class NotesUnReadMarks
Private DocList List As NoteIndex
Private DocArray() As String
Private NoteID As Long
Private hUnreadTable As Integer
Private hOriginalTable As Integer
Private rc As Integer
Private hDb As Long
Private dbNotesDatabase As NotesDatabase
Private sPrvServer As String
Private sPrvFilePath As String
Private sPrvDatabase As String
Private sPrvUsername As String
Private lPrvFirstNoteID As Long
Private lPrvLastNoteID As Long
Sub Delete
Call W32_IDDestroyTable(hUnreadTable)
Call W32_NSFDbClose(hDb)
End Sub
Sub New (inpNotesDatabase As NotesDatabase, inpUserName As String)
Dim lCurrentNoteID As Long
Dim iPrvScanFlag As Integer
Set Me.dbNotesDatabase = New NotesDatabase(inpNotesDatabase.Server,inpNotesDatabase.FilePath)
Me.sPrvServer = inpNotesDatabase.Server
Me.sPrvFilePath = inpNotesDatabase.FilePath
Me.sPrvUserName = inpUserName
If Me.dbNotesDatabase Is Nothing Then
Error 14005, "NotesUnreadMarks: Invalid database object."
End If
If Me.sPrvServer = "" Then
sPrvDatabase = Me.sPrvFilePath
Else
sPrvDatabase = Me.sPrvServer + "!!" + Me.sPrvFilePath
End If
'Open the target database
Me.rc = W32_NSFDbOpen(sPrvDatabase, Me.hDb)
If Me.rc <> 0 Then
Error 14001, "NotesUnreadMarks: Unable to open database."
End
End If
'Initialise IDTable variables
Me.hUnreadTable = 0
'Get the unread list
Me.rc = W32_NSFDbGetUnreadNoteTable(Me.hDb, Me.sPrvUserName, Len(Me.sPrvUsername), True, Me.hUnreadTable)
If Me.rc <> 0 Then
Error 14002, "NotesUnreadMarks: Unable to get unread marks."
End
End If
If Me.hUnreadTable = 0 Then
Error 14003, "NotesUnreadMarks: Unread table is null."
End
End If
'Refresh the Unread table
Me.rc = W32_NSFDbUpdateUnread(Me.hDb, Me.hUnreadTable)
If Me.rc <> 0 Then
Error 14004, "NotesUnreadMarks: Error refreshing the unread note table."
End
End If
Me.NoteID = 0
lCurrentNoteID = 0
iPrvScanFlag = True
While (W32_IDScan(Me.hUnreadTable, iPrvScanFlag, Me.NoteID))
If iPrvScanFlag Then
lPrvFirstNoteID = Me.NoteID
iPrvScanFlag = False
End If
If Not lCurrentNoteID = 0 Then
Me.DocList(Hex(lCurrentNoteID)).NextNoteID = Me.NoteID
Me.DocList(Hex(Me.NoteID)).PrevNoteID = lCurrentNoteID
End If
Me.DocList(Hex(Me.NoteID)).NoteID = Me.NoteID
lCurrentNoteID = Me.NoteID
Wend
lPrvLastNoteID = lCurrentNoteID
End Sub
Public Function Server As String
Server = Me.sPrvServer
End Function
Public Function FilePath As String
FilePath = Me.sPrvFilePath
End Function
Public Function UserName As String
UserName = Me.sPrvUserName
End Function
Public Function GetFirstDocument As Variant
Set GetFirstDocument = Me.dbNotesDatabase.GetDocumentByID(Hex(lPrvFirstNoteID))
End Function
Public Function GetLastDocument As Variant
Set GetLastDocument = Me.dbNotesDatabase.GetDocumentByID(Hex(lPrvLastNoteID))
End Function
Public Function GetNextDocument(inpNotesDocument As NotesDocument) As Variant
Dim IndexPoint As Long
IndexPoint = DocList(inpNotesDocument.NoteID).NextNoteID
If IndexPoint = 0 Then
Erase DocList(inpNotesDocument.NoteID)
Set GetNextDocument = Nothing
Else
Set GetNextDocument = Me.dbNotesDatabase.GetDocumentByID(Hex(IndexPoint))
End If
End Function
Public Function GetPrevDocument(inpNotesDocument As NotesDocument) As Variant
Dim IndexPoint As Long
IndexPoint = DocList(inpNotesDocument.NoteID).PrevNoteID
If IndexPoint = 0 Then
Erase DocList(inpNotesDocument.NoteID)
Set GetPrevDocument = Nothing
Else
Set GetPrevDocument = Me.dbNotesDatabase.GetDocumentByID(Hex(IndexPoint))
End If
End Function
Function IsUnread(inpNotesDocument As NotesDocument) As Integer
If DocList(inpNotesDocument.NoteID).NoteID = 0 Then
Erase DocList(inpNotesDocument.NoteID)
IsUnread = False
Else
IsUnread = True
End If
End Function
Sub MarkDocumentRead(inpNotesDocument As NotesDocument)
Dim NoteID As Long
NoteID = DocList(inpNotesDocument.NoteID).NoteID
If NoteID = 0 Then
Exit Sub
End If
'Copy the table so that changes can be merge to the original
Me.rc = W32_IDTableCopy(Me.hUnreadTable, Me.hOriginalTable)
If Me.rc <> 0 Then
Error 14006, "NotesUnreadMarks: Unable to copy unread table."
End
End If
'Refresh the Unread table
Me.rc = W32_NSFDbUpdateUnread(Me.hDb, Me.hUnreadTable)
If Me.rc <> 0 Then
Error 14004, "NotesUnreadMarks: Error refreshing the unread note table."
End
End If
If W32_IDIsPresent (Me.hUnReadTable, NoteID) Then
Me.rc = W32_IDDelete (Me.hUnReadTable, NoteID, &h0)
If Me.rc = 0 Then
Me.rc = W32_NSFDbSetUnreadNoteTable(Me.hDb, Me.sPrvUserName, Len(Me.sPrvUsername), True, Me.hOriginalTable, Me.hUnreadTable)
If Me.rc = 0 Then
If DocList(inpNotesDocument.NoteID).NoteID = lPrvLastNoteID Then
lPrvLastNoteID = DocList(inpNotesDocument.NoteID).PrevNoteID
End If
Erase DocList(inpNotesDocument.NoteID)
End If
End If
End If
If Me.hOriginalTable <> 0 Then
Call W32_IDDestroyTable(hOriginalTable)
End If
End Sub
Sub MarkDocumentUnread(inpNotesDocument As NotesDocument)
Dim NoteID As Long
If inpNotesDocument Is Nothing Then Exit Sub
NoteID = Clng("&H" + inpNotesDocument.NoteID)
'Copy the table so that changes can be merge to the original
Me.rc = W32_IDTableCopy(Me.hUnreadTable, Me.hOriginalTable)
If Me.rc <> 0 Then
Error 14006, "NotesUnreadMarks: Unable to copy unread table."
End
End If
'Refresh the Unread table
Me.rc = W32_NSFDbUpdateUnread(Me.hDb, Me.hUnreadTable)
If Me.rc <> 0 Then
Error 14004, "NotesUnreadMarks: Error refreshing the unread note table."
End
End If
Me.rc = W32_IDInsert (Me.hUnReadTable, NoteID, &h0)
If Me.rc = 0 Then
Me.rc = W32_NSFDbSetUnreadNoteTable(Me.hDb, Me.sPrvUserName, Len(Me.sPrvUsername), True, Me.hOriginalTable, Me.hUnreadTable)
If Me.rc = 0 Then
DocList(inpNotesDocument.NoteID).NoteID = NoteID
DocList(Hex(lPrvLastNoteID)).NextNoteID = NoteID
DocList(inpNotesDocument.NoteID).PrevNoteID = lPrvLastNoteID
DocList(InpNotesDocument.NoteID).NextNoteID = 0
lPrvLastNoteID = NoteID
End If
End If
If Me.hOriginalTable <> 0 Then
Call W32_IDDestroyTable(hOriginalTable)
End If
End Sub
End Class