Mail in what folders(s)?


How can I add a column that shows what folders the different mails are stored in?

I'm using Notes 4.6.7
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

First, you need to enable IMAP-compatible folder handling.  To do this, run the server CONVERT command with the -m paraneter against the mailbox, e.g., LOAD CONVERT -M mail\klunde.nsf

Interesting task. But you cannot do it in a column formula. The only way is to write this information into the document, which is probably could be done at postdragdrop event of the database, and in every part of code where you are moving documents to folders.
Or and there is an event QueryAddToFolder  for the views and folders which is exactly what you need.
Become a Microsoft Certified Solutions Expert

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

But that only soves half your problem; the other half is even more diificult.

When IMAP references are enabled, the following additional features are available for each document:

1) When accessed via NotesDocument (or lotus.notes.Document), there is a property called FolderReferences.  This property is an array of strings.  The strings are folder names.  But there is no equivalent @Function or field

2) There are three special fields on teh document $Folder, $FolderRef, and $FolderRefFlags.  $FolderRef is the source of information for FolderReferences.  But, while FolderReferences contains view names, $FolderRef does not. Instead, it is a text list of folder UniversalID strings, the 32-hex-digit internal key of a folder's design record. FolderReferences is "nice enough" to look up taht information for you.

3) Two special views are added.  One, ($FolderRefInfo), is all the document categorized on $FolderRef.  the other view shows a list of all folders, with two columns.  the first column is the folder's UNID, the second column is teh folder's name.  the first column is sorted.
qwaletee: in order to use these properties klunde should upgrade to R5

Now, how do you put it all together?  The view column can't make use of FolderReferences, because it is a property of the object model, while columns onlyhave fields and @functions.  The only field it has is $FolderRefs, and that would work, except I'm sure showing the folder UNID instead of its name is unacceptable.

So, what can you do?  There are two ways to handle it.

1) Don't show a column.  Instead, add a view action taht when clicked displasy teh highlighted document's folders.  the following code wuld do the trick:
Dim s as new notesSession
If Not s.currentdatabase.folderreferencesEnabled Then
  Msgbox "This database does need CONVERT -M before this feature will work"
End If
Dim folderList as string
Forall foldername in s.DocumentContext.folderReferences
  folderList = folderList & Chr$(13) & folderName
End Forall
If folderList = "" Then
  MsgBox "No folders for this document"
  Msgbox "Folders:" & folderList
End If

2) You can run code on your documents that will add a field to the document conatining the folder name. the code is fairly simple -- similar to teh code above.  But...
a) it would have to be run as an agent against all existing documents
b) it would have to run against all messages when they arrive
c) you would have to add it in to all the Move to folder objects and Add to folder events

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
No, they are available in 4.6 as well.
klundeAuthor Commented:
This looks very promesing!

But a slight problem. My Notes states that .folderreferencesEnabled is not a member of this class.
Hmm... folder references might have been added to the object model in 5, I'll have to check.  But the $Folder field hs been there since 4.5 or 4.6 for sure.  You can see this if you have it enabled for your malbox.

Here is sample code that would be the equivalent if you cold not use folder references in the object model...

**** Instead of:

Forall foldername in s.DocumentContext.folderReferences
  folderList = folderList & Chr$(13) & folderName
End Forall

**** Use:

Dim folderNames List as string, folderName as string, folder as notesDocument
Forall folderID in s.DocumentContext.~$FolderRef
  If IsElement(folderNames(folderID)) Then
    foldername = folderNames(folderID)
    set folder s.currentDatabase.getDocumentByUNID(folderID)
    foldername = folder.~$Title(0)
    foldernames(folderID) = folderName
  End If
  folderList = folderList & Chr$(13) & folderName
End Forall
klundeAuthor Commented:
This works!
Great! Thanks!

(after changing to "set folder = s.curr.....")
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.