Getting the unread count from inbox folder of mailbox

Hi,

I am facing a problem in finding the unread count from inbox folder of the mail box.

I am in need of a lotus script which will find the unread count from the mail box.

Could any one help me out?

thanks in advance

rgds

chandra kanth

Subject: Unread count using agent

This agent script runs on all unread documents, and its purpose is to put unread documents into a folder. If the agent does not contain a search, UnprocessedDocuments returns all unread documents in the database each time the agent runs, regardless of whether the agent has already run on some of the unread documents.

If the agent does contain searches, UnprocessedDocuments returns all unread documents in the database that meet the search criteria, regardless of whether the agent has already run on some of the unread documents.

Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim collection As NotesDocumentCollection

Dim doc As NotesDocument

Set db = session.CurrentDatabase

Set collection = db.UnprocessedDocuments

Set doc = collection.GetFirstDocument()

While Not(doc Is Nothing)

Call doc.PutInFolder _

( "Stop dreaming! Read these documents!",True )

Set doc = collection.GetNextDocument(doc)

Wend

End Sub

cheers,

Tom

Subject: Getting the unread count from inbox folder of mailbox

I am not sure what you are trying to do, but the client does show you the unread count on the database icon and in the folder name when you open the mail box.

Subject: RE: Getting the unread count from inbox folder of mailbox

Hi,Thanks for the response.

I am trying to get the unread mail count from inbox folder of the mail box through lotus script.

Could u please tell how it can be done.

This is urgent.

thanks & regards

chandra kanth.

Subject: RE: Getting the unread count from inbox folder of mailbox

If you start the agent manually, you can set it to run on all unread documents in the view…then the count is the db.unprocesseddocuments count…don’t know what you’d do in the background tho.

Subject: RE: Getting the unread count from inbox folder of mailbox

You can use LotusScript along with the C API to get this information:

Put the following in your (Declarations) section:

Declare Function NSFDbOpen Lib “nnotes.dll” (Byval PathName As String,rethDB 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 UserNameLength As Integer,_

Byval fCreateIfNotAvailable As Boolean,_

rethUnreadList 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

Then the following function will return the unread count for a particular user in a particular database:

Function GetUnreadCount(server As String,database As String,username As String) As Long

Dim rc As Integer

Dim hDB As Long

Dim hTable As Long

GetUnreadCount=-1

rc=NSFDbOpen(server+"!!"+database,hDB)

If rc=0 Then

	rc=NSFDbGetUnreadNoteTable(hDB,username,Len(username),0,hTable)

	If rc=0 Then

		GetUnreadCount=IDEntries(hTable)

		IDDestroyTable hTable

	End If

	NSFDbClose hDB

End If	

End Function

Make sure the username is passed in full canonical format (e.g. UserName property of NotesSession)

Regards,

Roberto

Subject: RE: Getting the unread count from inbox folder of mailbox

It is so interesting !!! I have tried your code but experimenting problems with this line:

GetUnreadCount=IDEntries(hTable)

Furthermore I wonder if you could explain how we can use this code (where, etc.)

Kind regards,

Diego Gómez

Subject: ignore