Home > Domino Tips > Developer > LotusScript > Putting an end to the frustration of mail merge
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

LOTUSSCRIPT

Putting an end to the frustration of mail merge


Chuck Connell
06.27.2005
Rating: -3.75- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


During the 15 years I've been involved with Lotus Notes, many people have asked me about mail merge from Notes to Microsoft Word. I usually give them a vague answer along the lines of, "Yeah, you can do it. I wrote some code a while ago that worked. But I can't find it now."

Now consider that one of the most common questions for the Microsoft support department is how to do mail merge, and it becomes clear that mail merge is a source of endless frustration for users. I hope that this article will solve the problem, once and for all, at least when passing data from Notes to Word. In this article, I'll first explain how to use the sample mail-merge application that I wrote, then describe the LotusScript code that does the work.

Notes output to Word is driven by a setup parameter that specifies the contents of the exported data. Within the Notes database, find the view named Settings, then open the parameter named Export - Mail Merge. The first line of the setup specifies the default name of the export file from Notes. The second line controls whether a header line is included in the export. (It usually is.) The remaining lines specify the names of the Notes fields that are included in the export.

To perform a data export, the Notes user selects any set of documents, pulls down the Action menu, and executes Mail Merge. You can try this yourself with the sample. First, create a directory named c:\mail-merge\ and use the view All Form1 to select some documents. When testing the export, you should use the default name for the export file, because the sample Word file is expecting that. After doing the export, examine the output file to verify that the selected data is present. Because there is a TAB character between each data field, the columns may not line up neatly when you look at the file on the screen, but the file is okay

The sample Word document named Customer Letter uses the Notes export file. The d


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


RELATED CONTENT
LotusScript
LotusScript sorts lists alphabetically
LotusScript code rebuilds corrupted busytime.nsf file
Soft-code item names to facilitate LotusScript management
LotusScript agent automates selective mail file replication
LotusScript filters and attaches files to a Notes form
How to create mail files using a LotusScript agent
Extract value pairs from text arrays with LotusScript
Mass-input form uses LotusScript to ease large-scale employee moves
LotusScript button updates email addresses in Lotus Notes PAB
Code exports Lotus Notes data to an OpenOffice Calc spreadsheet

LotusScript
LotusScript sorts lists alphabetically
Run or restart Notes/Domino agents via text messages
LotusScript code rebuilds corrupted busytime.nsf file
Soft-code item names to facilitate LotusScript management
LotusScript agent automates selective mail file replication
Can I create and copy Microsoft Excel spreadsheets with LotusScript?
LotusScript filters and attaches files to a Notes form
How to create mail files using a LotusScript agent
Can you use LotusScript to read a text file attached to a Notes doc?
Extract value pairs from text arrays with LotusScript

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary


etails of how mail merge works within Word vary, depending on the version of Word you have. A simple test is to use the next/last record buttons on the Word mail-merge toolbar. (The mail-merge toolbar should appear when you open the sample Word document. The next/last record buttons are left and right arrows.) You should see each "merged" letter in turn, one for each record exported from Notes.

The coding behind this sample uses two constructs: a simple agent, and the body of the code within a script library routine. The agent, named Mail Merge, contains only one line, which is a call to the script routine named ExportData within the library named MiscLib. The single parameter for the script call is the name of the user-definable setup parameter (Export - Mail Merge). The reason for this arrangement is so that you can easily create other instances of mail merge. You might want to export a different set of fields for certain Word documents, or to export a different set of Notes documents that contain different field names. You can do either without any new programming. Just create another setup parameter, say Export - Mail Merge 2, and another agent, say Mail Merge 2. The new agent is just like the current one, except that it includes the name of the new setup parameter in its call to the script routine.

The LotusScript routine (ExportData) includes generous comments and should be readable to those who want to see how it works. One way to possibly improve the code would be to include the field separation character (currently TAB) as one of the lines in the user-definable setup. I did not do so because TAB is so commonly used as a field separator that it seemed safe to leave that definition within the code. But if any reader wants to make this change, or finds a bug in the code, please let me know!

Chuck Connell is president of .CHC-3 Consulting, which helps organizations with all aspects of Domino and Notes. He can be reached at Connell@chc-3.com.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.


Submit a Tip




DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts