|
|
发表于 2004/3/17 13:43:56
|
显示全部楼层
Declare Sub W32_OSLoadString Lib "nnotes.dll" Alias "OSLoadString" (Byval null1 As Long, Byval sError As Integer, Byval errstr As String, Byval lenstr As Integer)
Declare Function W32_NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" ( Byval dbName As Lmbcs String, hdb As Long ) As Integer
Declare Function W32_NSFDbClose Lib "nnotes.dll" Alias "NSFDbClose" ( Byval hdb As Long ) As Integer
Declare Sub W32_OSPathNetConstruct Lib "nnotes.dll" Alias "OSPathNetConstruct" (Byval portName As Lmbcs String, Byval ServerName As Lmbcs String, Byval FileName As Lmbcs String, Byval retPathName As Lmbcs String)
Declare Function W32_NSFDbGetUnreadNoteTable Lib "nnotes" Alias "NSFDbGetUnreadNoteTable" (_
Byval hDB As Long, Byval UserName As String, Byval UserNameLength As Integer, Byval fCreateIfNotAvailable As Integer, _
rethUnreadList As Long) As Integer
Declare Function W32_NSFDbUpdateUnread Lib "nnotes" Alias "NSFDbUpdateUnread"(Byval hDataDB As Long, Byval hUnreadList As Long) As Integer
Declare Function W32_IDEntries Lib "nnotes" Alias "IDEntries" (Byval hTable As Long) As Long
Sub Initialize
Dim ndb As New NotesDatabase("","")
Dim s As New NotesSession
Dim hdb As Long ' db handle (integer for Mac, AIX, SUN Solaris and AS400)
Dim irc As Integer ' return status
Dim rethUnreadList As Long ' ID table handle
Call ndb.openMail
hDb = openDb(ndb)
If hDB=0 Then
Print "failed to open mail"
Else
IRC% = W32_NSFDbGetUnreadNoteTable (hDB , s.username, Len(s.username) , 1, rethUnreadList)
If irc%<>0 Then
Print getError(irc%)
Else
W32_NSFDbUpdateUnread hDb, rethUnreadList
Print s.username, "mailfile contains", W32_IDEntries (rethUnreadList),"unread document(s)"
End If
w32_NSFDBClose hdb
End If
End Sub
Function openDb(ndb As NotesDatabase) As Long
' return db handle
Dim retPath As String*1024, h As Long
Dim irc As Integer
W32_OSPathNetConstruct "",ndb.server, ndb.filepath, retPath
irc% = W32_NSFDbOpen (retPath, h)
If irc%<>0 Then
Print getError(irc%)
End If
openDb = h
End Function
Function getError (enum As Integer) As String
Dim s As String*256
W32_OSLoadString 0, enum And &h07FFFFFFF, s, 256
getError = Strleft(s, Chr(0))
End Function |
|