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, Domino, Workplace and WebSphere tips and advice
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
Update the ACL from the Roles view with LotusScript
LotusScript agent moves tagged spam email to junk mail folder
Create a personalized greeting for Lotus Notes database users
Fail-safe rich-text validation using LotusScript
How to export Lotus Notes views to a Microsoft Excel database
Create file system labels for Microsoft Excel and Word mail merges
Fix Lotus Notes 8.0 issues when launching Microsoft Office applications
Capture rich-text comments in Lotus Notes fields using LotusScript
Retrieve cell values from tables in a Lotus Notes rich-text field
Adding new variable-sized, multi-value fields to Lotus Notes documents

Lotus Notes Domino Mailbox Management
LotusScript agent moves tagged spam email to junk mail folder
Limit the size of incoming email attachments to a Lotus Domino server
LotusScript to extract and move attachments to a Lotus Notes mailbox or file folder
Sending specific agent errors to a mailbox instead of debugging
Setting corporate mail file size policies on NSF files
No more delayed email
Application for queueing non-delivery reports on hub mail server
Need to restrict who can send Internet mail and from where
Can Microsoft Outlook be used with Domino without installing Notes client?
Impact of user manually compacting mail database

LotusScript
Update the ACL from the Roles view with LotusScript
LotusScript agent moves tagged spam email to junk mail folder
Set a value in a field existing in another Lotus Notes database
Create an automatic scheduled view export in Excel
Top 10 LotusScript tips
Create a personalized greeting for Lotus Notes database users
Fail-safe rich-text validation using LotusScript
How to export Lotus Notes views to a Microsoft Excel database
Modifying LotusScript code for date and time handling
Create file system labels for Microsoft Excel and Word mail merges

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.

HomeNewsTopicsITKnowledge ExchangeTipsAsk the ExpertsWebcastsWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




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