Ok, it’s not magic but it’s really handy to know… The other week I was asked if it was possible to move an email message from any folder in a users mailbox to a special archive database just by having the user drag and drop it into a special folder that would be added to their mailfile. Here’s what I came up with…
The first step in this proceedure was to create a copy of the standard mail template and then add a new folder to it. You can call this folder anything you want except ‘Archive’, If you call it Archive then something else happens when you drag and drop an email message into it.. Once you have added the new folder you can either add it to the standard outline or do nothing with it to allow Lotus Notes to list it under the folders section of the outline.
Now you need to open the design of the ($Inbox) folder and find the QueryAddToFolder event and add in the following code :
Sub Queryaddtofolder(Source As Notesuiview, Target As Variant, Continue As Variant)
Select case Target
' This is the name of the extra folder added to the users mailfile
Case "Quick Archive"
Dim s As New NotesSession
Dim thisDB As NotesDatabase
Dim thisDoc As NotesDocument
Dim thisDocColl As NotesDocumentCollection
Dim nextDoc As NotesDocument
Dim targetDB As NotesDatabase
Set thisDB = s.CurrentDatabase
Set thisDocColl = Source.Documents
' This is the destination database. Set it to whatever location you want.
Set targetDB = s.GetDatabase(thisDB.Server,"Archivedocs.nsf",False)
Set thisDoc = thisDocColl.GetFirstDocument
While Not thisDoc Is Nothing
Set nextDoc = thisDocColl.GetNextDocument(thisDoc)
Set targetDoc = targetDB.CreateDocument
Call thisDoc.CopyToDatabase(targetDB)
' Remove the comment from next line if you want to delete the original document from the mailfile
' call thisDoc.RemovePermanently(true)
' Set the next line to TRUE if you want to actually move the document into the folder as well as move it to destination DB
continue = False
Set thisDoc = nextDoc
Wend
End Select
End Sub
This LotusScript was converted to HTML using the
ls2html routine,
provided by Julian Robichaux at
nsftools.com.
As you can see from the code there are a few options depending on if you want the original email message to disappear from the users mailfile or not.
Now, as the code has only been added to the ($Inbox) if you replace the design of the users mailfile with this new template then only email that are dragged from the users Inbox to the new folder will be effected. If you want to make sure that the changes are pushed out to every folder in the users mailfile then you need to use the convert command on the server console to update the users mailfiles. At the server console type the following :
TELL ROUTER QUIT
LOAD CONVERT -u MAIL* * newtemplate.ntf
LOAD ROUTER
The -u on the convert line will tell the convert process to replace the design of folders with the design of the ($Inbox) which will make sure the new code above is now part of all existing folders in the users mailfiles. Any new folders created by the user after this process will always have the design of the ($Inbox) folder by default.
By using more ‘cases’ in the ‘Select Case’ block then this code could be expanded with different folders that do different things when documents are dropped into them and this is not restricted to just mailfiles. You could add drag-drop code to applications, maybe in a case tracker system you could have a folder that if anything is dragged to it the case is closed and it and all related documents are moved to the archive. The possibilities are endless.
You must be logged in to post a comment.