Bulk export of attachments in Lotus Notes database 2

Source: Internet
Author: User

Batch export of attachments in Lotus Notes database

The Lotus Notes database is a document database where many attachments (such as Word documents, PDF documents, Excel documents, and so on) are often embedded in the rich text fields of the document. Users often need to export these attachments to other systems for use processing. However, when you need to export the attachments in many documents, you can only manually open individual documents individually and export the attachments, and then import the attachments to other systems, which can greatly reduce the efficiency when the number of attachments is large. From the user's point of view, this paper analyzes the requirements of batch export of several attachments and gives the corresponding solutions.

Introduction

The Notes database is a document database where many attachments (such as Word documents, PDF documents, Excel documents, and so on) are often embedded in the rich text fields of a document. These attachments are often important information for work, and users often need to export these attachments to other systems for processing, as shown in 1, where the user can save the selected attachment or all the attachments in the document to the local system. Sometimes users also need to export the attachments in multiple documents, as shown in 2, with attachments embedded in each document, and the user needs to export all the attachments in all documents that are selected. In this case, the user can only manually open individual documents individually and export the attachments to the system locally, and then import the attachments to other systems, which greatly reduces efficiency. The requirements for batch export of several attachments and the corresponding solutions are analyzed below.

Figure 1. The export of attachments in the Notes document is shown in Figure 2. Export of attachments in a multi-Notes document

Back to top of page

Requirements for bulk export of attachments and their solutions 1. Export to the Local system

Give an example. A company uses Excel form as the company's report management system, their business process is: First, the company regularly issued Excel report template for the whole company. Then, the grassroots business staff at the end of each cycle to fill out the report regularly, that is, fill in the template data, and then create a new Notes document, the Excel file embedded in this document submitted. Finally, the company's information collectors need to export Excel files from each Notes document, and then manually summarize and process the reports. Obviously, if you have a large number of business people, there will be a lot of Notes documents, and the way you manually export attachments will eventually overwhelm you. This article has developed a Savetolocalsystem agent program that can bulk export attachments from selected documents in the Notes database to the specified system directory. This agent is written in LotusScript, as shown in Listing 1, and can also be written using the Java API. The Savetolocalsystem Agent program and test data are included in annex ATTACHMENT.NSF of this article.

Listing 1. Bulk export of attachments to a local system in a multi-Notes document
 Type Browseinfo Howner as Long pidlroot as Long pszdisplayname as String lpsztitle As String ulflags as Long lpfn A s long LParam as Long iImage as long End Type const BIF_RETURNONLYFSDIRS = &h1 Const Bif_dontgobelowdomain = &amp ;  H2 Const BIF_STATUSTEXT = &h4 Const Bif_returnfsancestors = &h8 Const Bif_browseforcomputer = &h1000 Const Bif_browseforprinter = &h2000 Const MAX_PATH = 260 Declare Function shgetpathfromidlist Lib "Shell32" Alias "Shgetp Athfromidlista "(ByVal pidl as Long, ByVal Pszpath as String) as Long Declare Function shbrowseforfolder Lib" Shell3 2 "Alias" Shbrowseforfoldera "(Lpbrowseinfo as Browseinfo) as Long Declare Sub cotaskmemfree Lib" Ole32 "(ByVal PV A  s Long) Declare Function getdesktopwindow Lib "user32" () as Long Sub Initialize () Dim session as New Notessession  Dim db As NotesDatabase Dim collection As Notesdocumentcollection Dim doc As NotesDocument Dim rtitem As Variant Dim Notesitem as Notesitem     Dim bi As Browseinfo Dim pidl As Long Dim path As String Dim pos As Integer Bi.howner = GetDesktopWindow () bi . pidlroot = 0& bi.lpsztitle = "Select Directory to save the attachments" Bi.ulflags = bif_returnonlyfsdirs Pidl = SH BrowseForFolder (BI) path = space$ (MAX_PATH) If shgetpathfromidlist (ByVal pidl, ByVal path) Then pos = InStr (Path, chr$ ( 0)) End If call CoTaskMemFree (pidl) Set db = session. CurrentDatabase Set collection = db. UnprocessedDocuments Set doc = collection. Getfirstdocument () While not (Doc was nothing)//Here the attachment is assumed to be embedded in the Body field, of course, you can also loop through all the fields of the document, and then handle the rich text field, extract the attachment S ET rtitem = doc. GetFirstItem ("Body") If (Rtitem. Type = richtext) then ForAll o in Rtitem. EmbeddedObjects If (o.type = embed_attachment) Then call O.extractfile           (Left (path, pos-1) & "\" & O.name) End If End ForAll End If Set doc = collection. GetnextdoCument (DOC) Wend End Sub 

Use the instructions: Add the Savetolocalsystem Agent to any Notes database, then select the document you want to export the attachment to in any view, then click Savetolocalsystem in the menu actions A dialog box will pop up to select the storage directory, 3, click OK, and the attachments in the selected document will be exported to the selected directory.

Figure 3. Bulk export of attachments in a multi-Notes document to Local System 2. Summarize to Notes document

For the example above, the administrator may also need to summarize attachments from different documents into one document in the Notes database, or to a document in another database. This article developed another savetonotesdatabase Agent that creates a new document in the specified Notes database and aggregates the attachments from the selected document into the document in batches. This Agent is also written in LotusScript, see Code Listing 2, can also be written using the Java API. The Savetonotesdatabase Agent program and test data are included in annex ATTACHMENT.NSF of this article.

Listing 2. Batch summarization of attachments in a multi-notes document to a Notes document
 Sub Initialize () Dim session As New Notessession Dim db As NotesDatabase Dim collection As Notesdocumentcolle Ction Dim doc As NotesDocument Dim rtitem As Variant Dim doc2 As NotesDocument Dim notesrichtextitem As Note  Srichtextitem Dim Notesitem As Notesitem Dim workspace As New Notesuiworkspace Dim result as Variant result = Workspace. Prompt ("Choose database to save the attachments", "") Set db = session. CurrentDatabase Set collection = db. UnprocessedDocuments Set doc = collection. Getfirstdocument () If result (0) = "" & result (1) = db. Filename then Set doc2 = db. CreateDocument () Else Dim DB2 as notesdatabase Set DB2 = session. Getdatabase (Result (0), result (1), False) Set doc2 = DB2. CreateDocument () End If//This assumes that the new document is based on the form "Main Topic" and summarizes the attachment into the Body Rich text field doc2. Form = "Main Topic" doc2. Subject = "New Attachment" Set Notesrichtextitem = new Notesrichtextitem (doc2, "Body" While not (Doc was nothing)//Here the attachment is assumed to be embedded in the Body field, of course, you can also loop through all the fields of the document, and then handle the rich text field, extract the attachment Set Rtitem = do C.getfirstitem ("Body") If (Rtitem. Type = richtext) then ForAll o in Rtitem.          EmbeddedObjects If (o.type = embed_attachment) Then call O.extractfile ("C:\temp\" & O.name) Call Notesrichtextitem.embedobject (Embed_attachment, "", "C:\temp\" & O.name) Kill "C:\temp\" & O.name End If End ForAll End If Set doc = collection. GetNextDocument (DOC) Wend call doc2. Save (False, True) End Sub

Using the same action as above, just this pop-up dialog box is used to select the storage database, 4, you can select a local Notes database, you can select a different server on the Notes database, click OK, then savetonotesdatabase Creates a new document in the database and summarizes the attachments in the selected document into the document.

Figure 4. The attachments in a multi-notes document are aggregated in bulk to the Notes document in 3. Export to Lotus Quickr site

As a new generation of document collaboration platforms, Lotus QUICKR provides powerful document management capabilities and provides customers with a range of powerful connectors (connectors) that can be installed in the form of plug-ins to common desktop applications, enabling these software-based Quickr Server Chinese file data access. In addition, Quickr provides users with a complete set of document management APIs for user customization and extension, the Content public API, which includes the WebService API and Rest API two parts.

After the Quickr Notes connector is installed, users can add attachments from the Notes database to the Quickr site, as shown in 1, similar to what is saved to the local system. If you need to add attachments from multiple documents, you also need to open each document in turn to add the attachments to a Quickr site. In the same way as in the above two cases, you can also develop an agent program to add batches of attachments from all selected documents to a Quickr site. This Agent can be written using the Java API to get attachments and add the acquired attachments to a site in Quickr using the WebService API writer.

Back to top of page

Conclusion

This paper introduces the requirement of batch export in three kinds of Notes database and the corresponding solution, and gives the implementation code of the first two solutions.

In the last 20 years, some Lotus customers have accumulated a lot of Domino applications, and most of them are in stable operation. However, as emerging technologies continue to emerge, these enterprises urgently need to reuse these existing IT assets to maximize the analysis and mining of valuable data stored in them, and expect effective integration with other emerging technologies. In addition to the above three requirements, users may also bulk import attachments into other systems, such as FileNet and some unstructured databases. If the reader is interested, you can refer to the methods in this article to implement other agents, using the appropriate APIs to bulk import the attachments to other systems.

Source:

http://www.ibm.com/developerworks/cn/lotus/notes-attachment-export/

Bulk export of attachments in Lotus Notes database 2

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.