Drag And Drop Magic

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.

Advertisements
Posted in None
3 comments on “Drag And Drop Magic
  1. Nice work. You might want to consider if you really want to alter the queryAddtoFolder of the inbox since this will modify the behavior of the inbox only. Furthermore you might experience an odd behavior: New folders that are created after the mail design upgrade will show the drag and drop functionality, old folder won’t unless/until you perform a upgrade folder design.I personally never understood why the event for queryaddtofolder is in the source folder and not the target. You might want to add your code into the Other/Database Resources/DatabaseScript/PostDragDrop Event (This is also the place where the “Archive” Folder magic happens. stw

    Like

  2. Declan Lynch says:

    The ‘Load Convert -u’ command will convert all the users folders to the same design of the ($Inbox) so the problem you describe with it only effecting the inbox won’t occur.

    Like

  3. Sean Burgess says:

    This is a version of what I like to call A Poor Man’s Archiving Solution. I implemented this at a previous company when they wanted to keep project related emails in a single mail archive for research purposes. Instead of putting any code in the actual mail file, I did the following:1. For each project, users would create a folder that would match the project number and name.2. I would create a single archive database on the server for each project. Each archive would contain an agent that would go through all the person documents in the NAB and look in their mail file for the corresponding folder. If found, it would move the mail to the archive.The positives of this approach was that I didn’t have to worry about keeping track of which users were on which project, important since they moved around a lot, and I didn’t have to mess with the mail template. Plus, since the agent ran on the server at night, there was almost no performance impact on the users. Sean—

    Like

Comments are closed.

Archives
%d bloggers like this: