Option Public
Option Explicit
Declare Function OSPathNetConstruct Lib "nnotes.dll" (Byval portName As Integer, _
Byval serverName As String, Byval fileName As String, Byval pathName As String) As Integer
Declare Function NSFDbOpen Lib "nnotes.dll" (Byval dbName As String, hDb As Long) As Integer
Declare Function NSFDbClose Lib "nnotes.dll" (Byval hDb As Long) As Integer
Declare Function NSFNoteDelete Lib "nnotes.dll" (Byval hDb As Long, Byval NoteID As Long, _
Byval flags As Integer) As Integer
Declare Function OSLoadString Lib "nnotes.dll" (Byval hModule As Long, Byval stringCode As Integer, _
Byval retBuffer As String, Byval bufferLength As Integer) As Integer
Const ERR_MASK = &H3fff
Const PKG_MASK = &H3f00
Const ERRNUM_MASK = &H00ff
Const UPDATE_FORCE = 0001
Const UPDATE_NAME_KEY_WARNING = 0002
Const UPDATE_NOCOMMIT = 0004
Const UPDATE_NOREVISION = 0256
Const UPDATE_NOSTUB = 0512
Const UPDATE_INCREMENTAL = 16384
Const UPDATE_DELETED = 32768
Sub Initialize
Dim hexNoteID As String
hexNoteID = Inputbox$("Please enter a valid NoteID for deletion, using Hex notation:")
If (hexNoteID = "") Then
Print "Nothing entered. Exiting."
Exit Sub
End If
Dim session As New NotesSession
Dim db As NotesDatabase
Dim result As String
Set db = session.CurrentDatabase
result = APIStublessDelete(db, hexNoteID)
If (result = "") Then
Print "Successfully deleted NoteID " & hexNoteID
Else
Print result
End If
End Sub
Function APIStublessDeleteWrapper (doc As NotesDocument) As String
APIStublessDeleteWrapper = APIStublessDelete(doc.ParentDatabase, doc.NoteID)
End Function
Function APIStublessDelete (db As NotesDatabase, hexNoteId As String) As String
On Error Goto processError
Dim hDb As Long
Dim convertID As Long
Dim pathName As String*256
Dim result As Integer
Call OSPathNetConstruct(0, db.Server, db.FilePath, pathName)
result = NSFDbOpen(pathName, hDb)
If result <> 0 Then
APIStublessDelete = "Cannot open database " & db.FilePath & " on server " & db.Server & _
". Error was " & Cstr(result) & ": " & GetAPIError(result)
Exit Function
End If
convertID = Clng(Val("&H" & hexNoteId)) And &H7FFFFFFF
result = NSFNoteDelete(hDb, convertID, UPDATE_NOSTUB Or UPDATE_FORCE)
If result <> 0 Then
APIStublessDelete = "Unable to delete doc" & _
". Error was " & Cstr(result) & ": " & GetAPIError(result)
End If
closeDb:
Call NSFDbClose(hDb)
endOfFunction:
Exit Function
processError:
APIStublessDelete = "Notes error " & Err & " occurred: " & Error$
If (hDb > 0) Then
Call NSFDbClose(hDb)
End If
Exit Function
End Function
Function GetAPIError (errorCode As Integer) As String
Dim errorString As String*256
Dim returnErrorString As String
Dim resultStringLength As Long
Dim errorCodeTranslated As Integer
errorCodeTranslated = (errorCode And ERR_MASK)
resultStringLength = OSLoadString(0, errorCodeTranslated, errorString, Len(errorString) - 1)
If (Instr(errorString, Chr(0)) > 0) Then
returnErrorString = Left$(errorString, Instr(errorString, Chr(0)) - 1)
Else
returnErrorString = errorString
End If
GetAPIError = returnErrorString
End Function
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.