How to find List of Users in the Names & Address Books who have MailForward checked on

Please help !!!

How to find List of Users in the Names & Address Books who have MailForward checked on

How can I get the list of users (which flag I need to ckeck to find if MailForward is on for them)

Subject: How to find List of Users in the Names & Address Books who have MailForward checked on

1 - Create a Lotusscript agent, action menu triggered, target - none (in any database)2 - Import the following code:

Option Public

Option Declare

'PUT THESE IN THE DECLARATIONS SECTION

Dim s As NotesSession

Dim domdir As NotesDatabase

Dim personName As NotesName

Dim personList List As String

Dim MailAddress As String

Dim fileID As Integer

Dim filePath As String

'Constants

Const domdirserver$ = “YOURSERVERNAMEHERE”

Sub Initialize

Set s = New NotesSession

Set domdir = s.GetDatabase(domdirserver$, "names.nsf")

'That assumes the agent runs in the NAB

'use GetDatabase if it’s running in another DB

Call PopulatePersonList

fileID = Freefile

filePath = "C:\Temp\ForwardedAccounts.txt"

If Dir(filePath) <> "" Then Kill filePath

Open filePath For Output As fileID

Forall account In personList

	Set personName = New NotesName(Listtag(account))

	Print #fileId, personName.Abbreviated & " - " & account

End Forall 

Close fileID

'Create and send notification

Dim mailDoc As New NotesDocument(domdir)

Call mailDoc.ReplaceItemValue("SendTo","YOUR NAME (CN) HERE")

Dim body As New NotesRichTextItem(mailDoc, "Body")

Call body.AppendText("Policy scan completed at " + Cstr(Now))

Call body.AddNewline(2,True)

Call mailDoc.ReplaceItemValue("Subject","Following People have forwarding addresses")

Call body.EmbedObject(EMBED_ATTACHMENT, "", filePath)

Call mailDoc.Send(False)

End Sub

Sub PopulatePersonList

'This prevents doing a real lookup for every person

'by creating a lookup table in memory

Dim peopleView As NotesView

Dim personDoc As NotesDocument

Set peopleView = domdir.GetView("($VIMPeople)")

Set personDoc = peopleView.GetFirstDocument

Do Until personDoc Is Nothing

	If personDoc.GetItemValue("MailAddress")(0) <> "" Then

		'Only populate the list if the person has a forwarding address

		personList(personDoc.GetItemValue("FullName")(0)) = personDoc.GetItemValue("MailAddress")(0)	

	End If

	Set personDoc = peopleView.GetNextDocument(personDoc)

Loop

End Sub

3 - Change the bits in the code that reference a servername for the domino directory and your own personal email/notes name

4- Run agent. You will be mailed a text file containing the abbreviated names of everyone in your corporate NAB/domino directory who has a forwarding address, along with that address.

5 - Tweek the code as you wish to change the output method, send to a group, whatever. If you put this into the NAB itself, you can skip the bits about referencing a specific server, and just use set domdir = s.currentdatabase

Thanks to Bill Buchan for his great promotion of Lotusscript Lists which made this possible/easy. http://www.billbuchan.com/web.nsf/htdocs/BBUN67JJCV.htm

Thanks to Stan Rogers who wrote a very similar agent that I used as a starting point: http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/8c6522b1bd6065b5852570cb007fdb4c?OpenDocument

Kevin

http://www.lotusguru.com