Home > Domino Tips > Developer > LotusScript > Show unread marked Lotus Notes email messages using LotusScript
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

LOTUSSCRIPT

Show unread marked Lotus Notes email messages using LotusScript


Rob Goudvis
12.18.2007
Rating: -3.78- (out of 5) Hall of fame tip of the month winner


Lotus Notes and Domino tips, tutorials and how-to articles
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


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.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google



RELATED CONTENT
LotusScript
LotusScript finds the first occurrence of a string from the right
Clear Recent Contacts view and prevent repopulation in Lotus Notes 8.x
Search Microsoft Active Directory with LotusScript
Three steps to trap and handle save conflicts with LotusScript
Troubleshoot agents by displaying LotusScript variables online
LotusScript sorts lists alphabetically
LotusScript code rebuilds corrupted busytime.nsf file
Soft-code item names to facilitate LotusScript management
LotusScript agent automates selective mail file replication
LotusScript filters and attaches files to a Notes form

Lotus Notes Domino Mailbox Management
Secure Lotus Notes/Domino 8.x from mail to unknown recipients
Run or restart Notes/Domino agents via text messages
How to create mail files using a LotusScript agent
How to turn off the message recall feature in Lotus Notes 8
Domino server setting and email policy tricks admins must know
Customize the principal field of outgoing email messages
LotusScript action button manages Lotus Notes mail files
JavaScript error encountered when opening Lotus Notes email
Bringing MailRule documents back into view
LotusScript agent moves tagged spam email to junk mail folder

LotusScript
LotusScript finds the first occurrence of a string from the right
Clear Recent Contacts view and prevent repopulation in Lotus Notes 8.x
Search Microsoft Active Directory with LotusScript
Three steps to trap and handle save conflicts with LotusScript
Troubleshoot agents by displaying LotusScript variables online
LotusScript sorts lists alphabetically
Run or restart Notes/Domino agents via text messages
LotusScript code rebuilds corrupted busytime.nsf file
Soft-code item names to facilitate LotusScript management
LotusScript agent automates selective mail file replication

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts