Manage Learn to apply best practices and optimize your operations.

Show unread marked Lotus Notes email messages using LotusScript

Use this LotusScript and Formula language code to determine the read status of another user's Lotus Notes email messages.

With this LotusScript code, you can allow authorized users or administrators to identify the read status of another user's email messages. This is helpful in a situation, for example, where a secretary needs to know what email the boss has or hasn't seen. Please note the additional steps and code underneath this LotusScript code.

Lotusscript library called "UnreadMarks":

Declarations
------------
Const NOTE_CLASS_VIEW = 8
Const TYPE_TEXT = (5 * 256)
Const READ_BY_OWNER = "1"
Const UNREAD_BY_OWNER = "0"
Const READ_ITEM_NAME = "ReadByOwner"
Const INBOX = "($Inbox)"

Type DataRef
 type As Integer
 data As String*2
End Type

Declare Function NIFFindDesignNote Lib "nnotes.dll" 
(Byval hdb As Long, Byval noteName As String, 
Byval wFlags As Integer , NoteId As Long) As Integer

Declare Function NSFDbClose Lib "nnotes.dll" 
(Byval hDb As Long) As Integer Declare Function 
NSFDbGetUnreadNoteTable Lib "nnotes.dll" 
(Byval hDb As Long, Byval UserName As String, 
Byval NameLength As Integer, Byval Create As Integer, 
hUnreadTable As Long) As Integer Declare Function 
NSFDbOpen Lib "nnotes.dll" (Byval dbName As String, 
hDb As Long) As Integer Declare Function 
NSFDbSetUnreadNoteTable Lib "nnotes.dll" (Byval hDb 
As Long, Byval UserName As String, Byval NameLength 
As Integer, Byval Flush As Integer, Byval hOriginalTable As 
Integer, Byval hUnreadTable As Long) As Integer Declare 
Function NSFDbStampNotes Lib "nnotes.dll" (Byval hdb As
 Long, Byval htab As Long, Byval itemname As String, Byval 
itemlen As Integer, data As DataRef, Byval datalen As Integer) 
As Integer Declare Function NSFDbUpdateUnread Lib
 "nnotes.dll" (Byval hDb As Long, Byval hTable As Long) As 
Integer Declare Function 
NSFFolderGetIDTable Lib "nnotes.dll" 
(Byval hviewDB As Long, Byval hdataDB As Long, Byval viewid 
As Integer, Byval flags As Long, htable As Long) As Integer

Declare Function IDDestroyTable Lib "nnotes.dll" 
(Byval hTable As Long) As Integer Declare Function IDEntries
 Lib "nnotes.dll" (Byval hTable As Long) 
As Long Declare Function 
IDTableCopy Lib "nnotes.dll" (Byval hOriginalTable As Long, 
hNewCopy As Long) As Integer

Declare Function OSLoadString Lib "nnotes.dll" (Byval hMod As 
Long, Byval strCode As Integer, Byval strBuf As String, Byval 
bufLen As Integer) As Integer Declare Function 
OSPathNetConstruct Lib "nnotes.dll" (Byval portname As 
String, Byval servername As String, Byval filename As String, 
Byval pathname As String) As Integer

Dim status As Integer

Sub GetOwnerStatus
 Dim ws As New NotesUIWorkspace
 Dim session As New NotesSession 

 

 
Related resources from SearchDomino.com:
Tip: How to fix the Lotus Notes unread documents feature

Tip: When resetting your unread count, save your unread marks

Tip: Drive away the incorrect unread mail count problems

LotusScript Reference Center

Dim db As NotesDatabase Dim tserver As String Dim tdatabase As String Dim ownername As String Dim username As String Dim calprof As NotesDocument Dim inboxlist As Long Dim hDB As Long Dim dbp As String*256 Dim dbpath As String Dim itemname As String Dim data As DataRef Dim viewid As Long Dim flags As Long Dim iflags As Integer Dim ownerlist As Long Dim ownerreflist As Long Dim userlist As Long Dim userreflist As Long Set db = session.CurrentDatabase username = session.UserName tserver = db.Server tdatabase = db.FilePath Set calprof = db.GetProfileDocument ("CalendarProfile") If Not calprof Is Nothing Then If calprof.HasItem("Owner") Then ownername = calprof.GetItemValue("Owner")(0) status = OSPathNetConstruct(Null, tserver, tdatabase, dbp) dbpath = Trim$(dbp) status = NSFDbOpen(dbpath, hdb) If status <> 0 Then Call ErrorHandling("Open db") End If status = NSFDbGetUnreadNoteTable(hDB, username, Len(username), True, userlist) If status <> 0 Then Call ErrorHandling("Get old unread for userlist") End If status = IDTableCopy(userlist, userreflist) If status <> 0 Then Call ErrorHandling("Copy unread for userlist") End If status = NSFDbGetUnreadNoteTable(hDB, ownername, Len(ownername), True, ownerlist) If status <> 0 Then Call ErrorHandling("Get old unread for ownlerlist") End If status = IDTableCopy(ownerlist, ownerreflist) If status <> 0 Then Call ErrorHandling("Copy unread for ownerlist") End If iflags = NOTE_CLASS_VIEW status = NIFFindDesignNote(hDB, INBOX, iflags, viewid) If status <> 0 Then Call ErrorHandling("Get Inbox") End If flags = 0 status = NSFFolderGetIDTable(hDB, hDB, viewid, flags, inboxlist) If status <> 0 Then Call ErrorHandling("Get ID table for Inbox") End If itemname = READ_ITEM_NAME data.type = TYPE_TEXT data.data = READ_BY_OWNER status = NSFDbStampNotes(hDB, inboxlist, itemname, Len(itemname), data, 3) If status <> 0 Then Call ErrorHandling("Stamp notes read") End If itemname = READ_ITEM_NAME data.type = TYPE_TEXT data.data = UNREAD_BY_OWNER status = NSFDbStampNotes(hDB, ownerlist, itemname, Len(itemname), data, 3) If status <> 0 Then Call ErrorHandling("Stamp notes unread") End If IDDestroyTable(ownerlist) status = NSFDbGetUnreadNoteTable(hDB, ownername, Len(ownername), True, ownerlist) If status <> 0 Then Call ErrorHandling("Get new unread for ownerlist") End If status = NSFDbSetUnreadNoteTable(hDB, ownername, Len(ownername), True, ownerlist, ownerreflist) If status <> 0 Then Call ErrorHandling("Set unread for ownerlist") End If IDDestroyTable(userlist) status = NSFDbGetUnreadNoteTable(hDB, username, Len(username), True, userlist) If status <> 0 Then Call ErrorHandling("Get new unread for userlist") End If status = NSFDbSetUnreadNoteTable(hDB, username, Len(username), True, userlist, userreflist) If status <> 0 Then Call ErrorHandling("Set unread for userlist") End If IDDestroyTable(ownerlist) IDDestroyTable(ownerreflist) IDDestroyTable(userlist) IDDestroyTable(userreflist) IDDestroyTable(inboxlist) status = NSFDbClose(hDB) If status <> 0 Then Call ErrorHandling("Close db") End If ws.ViewRefresh End If End If Sub ErrorHandling(func As String) Dim msgbuf As String *256 Dim msg As String Call OSLoadString(0, status, msgbuf, 256) msg = Trim$(msgbuf) Print "Error during [" + func + "] " + msg End Sub

In your Lotus Notes inbox, add an icon column (3rd from the left) with this Formula language code:

@If(ReadByOwner="1"; 56; 0)
and this hide-when formula:
@GetProfileField("CalendarProfile"; "Owner")=@UserName

Then add an action (with the same hide-when formula) called "Get owner status" with this statement:

Call GetOwnerStatus

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip library by member Rob Goudvis. Please let others know how useful it is via the rating scale below. Do you have a useful Lotus Notes, Domino, Workplace or WebSphere tip or code snippet to share? Submit it to our monthly tip contest and you could win a prize.

This was last published in December 2007

Dig Deeper on Lotus Notes Domino Mailbox Management

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchExchange

SearchContentManagement

Close