Inbox showing 'filed' documents. Developers help wanted! (please :)

Hi All,

One of our users mail files has a big problem.

When we access his mail file we see all of his documents in the inbox. Even the ones that he has filed away into folders. (I know this is the case as I can ‘read’ one of the docs in the inbox and track it in his folders and of course it is ‘read’)

We have searched everywhere, called IBM and raised a PMR and basically we still have no solution. I have been led to believe that it is to do with the links in the $Inbox design element

My cry is to all you developers out there (I am but a humble admin) to see if anyone can help me!

I would like an agent that checks every message in the inbox and compares it to every message in the users folders. If it finds a match in the folder, it ‘removes’ it from the inbox and leaves it in the folder.

The logic is simple. But unfortunately so are my design skills. Does anyone think they are up to solve this challenge?

Insane amounts of thanks in advance

Michael

Subject: RE: Inbox showing ‘filed’ documents. Developers help wanted! (please :slight_smile:

If there are not a lot of folders, it’s not hard to do this manually; go to a folder, select all. Hold down Ctrl while you click the Inbox folder. Any documents that are still selected in the Inbox, are also in the folder you were just in.

Otherwise, you can do it with code, but it might be slow. If folder references are enabled in the database, and if they were enabled at the time the documents got into the folders that they’re in (besides the inbox) then you should be able to use a script like this to check each inbox document for membership in other folders.

Set view = db.GetView(“($Inbox)”)

Set doc = view.GetFirstDocument

Do Until doc Is Nothing

Set nextdoc = view.GetNextDocument(doc)		

i = 0

On Error 549 Goto noreferences

Forall FolderReference In doc.FolderReferences

	If FolderReference <> "" And FolderReference <> "($Inbox)" Then

		i=i+1

	End If

End Forall



If i <> 0 Then

	Call doc.RemoveFromFolder("($Inbox)")

End If

resumeLoop:

Set doc = nextdoc

Loop

Exit Sub

noreferences:

Resume resumeLoop

If folder references are not enabled, then you could try something like this, which is slower but should still work:

Forall view in db.Views

if view.isfolder and view.Name <> “($Inbox)” then

set entrycoll = view.AllEntries

call entrycoll.RemoveAllFromFolder(“($Inbox)”)

end if

end forall

Subject: RE: Inbox showing ‘filed’ documents. Developers help wanted! (please :slight_smile:

OK got the code running - a mate of mine helped me with a load of DIMs and variable stuff and told me it was lotusscript…

so the agent looked good… and it told me that folder refrences were not enabled…

so now i have to get the second agent option to work :slight_smile:

Subject: RE: Inbox showing ‘filed’ documents. Developers help wanted! (please :slight_smile:

Hi Andre,

The CTRL select method works a treat for small mail boxes.

I am having a lot more trouble with the coded version. Time is not a problem here, so if the agent works and it is the simplest thing to execute, then that is probably the way we will go…

First question:

When I create the agent do I do so using LotusScript or Formula? Currently I have selected formula.

Second question…

Is the syntax correct?

When I put the code you mentioned (either lot) in the agent i get an error that says:

An operator or semicolon wasexpected but none encountered: ‘view’

The word view is in red after the word Set on the very first line.

As I said… I am no developers armpit so any help you can provide is greatly appreciated. :slight_smile:

THanks again

Michael

Subject: RE: Inbox showing ‘filed’ documents. Developers help wanted! (please :slight_smile:

Hi Andre,

Thanks for the code… I haven’t tested it yet… but will in the very near future.

I also like the idea about selecting docs in the folder and flicking back to the inbox to see which ones are selected.

Will give both a try this week and let you know.

Thanks

Subject: stupid question

Did you already replace the mail template?

Subject: RE: stupid question

yeah we have replaced it with one straight out of the box and our modified one.

Subject: had to ask. (Said it was stupid.)

Subject: RE: had to ask. (Said it was stupid.)

lol it did have to be asked :slight_smile:

Subject: Inbox showing ‘filed’ documents. Developers help wanted! (please :slight_smile:

Michael, try this code I wrote for someone suffering the exact same problem. Copy and paste it to an agent in the mail file, run from actions menu, target all documents in database:Sub Initialize

Dim session As New NotesSession

Dim db As NotesDatabase

Dim inboxView As NotesView

Dim inboxVC As NotesViewEntryCollection

Dim inboxEntry As NotesViewEntry

Dim inboxDoc As NotesDocument

Dim folderView As NotesView

Dim viewArray() As Variant

Dim vc As NotesViewEntryCollection

Dim folderEntry As NotesViewEntry

Dim folderDoc As NotesDocument

Dim nextEntry As NotesViewEntry

Dim i,x,remcount As Integer

Set db = session.CurrentDatabase





'build a dynamic array of all folders in the database

Dim vCount As Integer

vCount = 0

Forall v In db.Views

	If v.IsFolder Then

		If Not (v.Name="($Inbox)") And Not (v.Name="($Trash)") Then

			Redim Preserve viewArray(vCount)

			viewArray(vCount) = v.Name

			vCount = vCount + 1

		End If

	End If

End Forall

' get the collection of docs in the inbox

Set inboxView = db.GetView("($Inbox)")

Set inboxVC = inboxView.AllEntries

' get the first entry

Set inboxEntry = inboxVC.GetFirstEntry

Set inboxDoc = inboxEntry.Document

' loop through all of them

remcount = 0

While Not (inboxDoc Is Nothing)

	For x = 0 To Ubound(viewArray)

		Set folderView = db.GetView(viewArray(x))

		' look for the current document in this folder

		Set vc = folderView.AllEntries

		Set folderEntry= vc.GetEntry(inboxEntry)

		If Not (folderEntry Is Nothing) Then

			' found a match

			Set folderDoc = folderEntry.Document

			If folderDoc.Form(0) = "Memo" Or folderDoc.Form(0)="Reply" Then

				'it's definitely an email

			'	If Msgbox("Found an email:" & Chr(10) & Chr(10) & "From: " & inboxDoc.From(0) &_

			'	Chr(10) & "Subject: " & inboxDoc.Subject(0) & Chr(10) & "Folder: " &_

			'	folderView.Name & Chr(10) & Chr(10) &_

			'	"Would you like to remove it from your inbox?", 4+32, "Found Match") = 6 Then

					' user wants to remove it

			'		Set NextEntry = inboxVC.GetNextEntry(inboxEntry)

			'		Call inboxDoc.RemoveFromFolder("($Inbox)")

’ Set inboxEntry = NextEntry

			'		Goto nextdoc

			'	Else

					' user wants to keep it

			'	End If

				Set NextEntry = inboxVC.GetNextEntry(inboxEntry)

				Call inboxDoc.RemoveFromFolder("($Inbox)")

				remcount = remcount + 1

				Set inboxEntry = NextEntry						

			End If ' doc is not an email

		End If ' could not find it

	Next x

		' there was no match in any folder, so move to the next document in the inbox

	Set inboxEntry = inboxVC.GetNextEntry(inboxEntry)

nextdoc:

	If Not (inboxEntry Is Nothing) Then 

		Set inboxDoc = inboxEntry.Document

	Else

		Set inboxDoc = Nothing

	End If

Wend

Msgbox "Folder Scan Agent removed " & Cstr(remcount) & " documents from your Inbox."

End Sub

Some of the lines will appear “green” as they are not in use. If you remove the apostrophe’s before the green lines, the code will prompt you every time it finds a match in another folder.

Hope that helps

Ben

Subject: RE: Inbox showing ‘filed’ documents. Developers help wanted! (please :slight_smile:

Thanks Ben,

This one ‘works’ straight out of the box.

It did not remove all pointers in one go, I had to run the agent about 10 times (to relocate about 460 pointers) and at the end when it was reporting no more objects to move there were still a few messages in the inbox.

But the agent has saved us loads of time and we are keeping it aside in case we experience the problem again.

Thanks Ben for your help.

Rgds

Michael