wissel.net

Usability - Productivity - Business - The web - Singapore & Twins

By Date: December 2014

Command line mail merge


As shown before mail merging with Notes and {{mustache}} is simple and easy to code. To be able to run merging on the command line, I modified the bean and removed the XPages dependency and added a static main function. Now you can run it off the command line easily. It requires 5 parameters:
  1. the database name
  2. the CSV file
  3. a file with a HTML message including {{mustache}} tags
  4. a file with a Text message including {{mustache}} tags
  5. The senders eMail

Read more

Posted by on 13 December 2014 | Comments (1) | categories: IBM Notes

Mail Merge with XPages


Being able to have individualized letters based on a template was one of the drivers to make Word processors popular. In the age of mass-communication of one. This tasks falls no longer to the printer, but your eMail processor. For a complete solution, check out Chris Toohey's excellent Mailer application, that is yours for USD 5.00 only.
I was wondering what it would take to build something similar, minus the address management, in XPages. I defined a few constraints:
  • I don't want to store the address list or the raw message
  • I need to be able to send images
  • I need to be able to fine tune the HTML
  • No sending of attachments required
  • Message needs to be individual using parameters (in the Body only), list of parameters will be flexible supplied together with the eMails as CSV data
So I created the MergeManager Java bean. Along the way I made a few experiences:
  • When bound to a bean the XPages RichText control wants a data type of com.ibm.xsp.http.MimeMultipart
  • The IBM Image upload doesn't work with a bean bound RichText control, but dragging and dropping works. I got rid of the button with a single line of code:
    config.removeButtons = 'IbmImage';
  • When adding the Dropdown for the variables, a simple change allowed me to show the View source button:
    {"name" : "mustache", "items" : ["mustache","Source"] });
  • I reused parts of Toni's eMail bean, which I stripped of the attachment function and added direct deposition into the mail.box. Works like a charm
  • There are lots of loose ends to consider: using the OpenNTF Domino API to gain easy access to theads to send the messages in the background would be top on the list. Allow template storage, different messages for HTML and Text (and EE), eMail preview some of the others. But that's a story for another time
The result is a reusable bean for custom mass eMails.

Read more

Posted by on 13 December 2014 | Comments (0) | categories: XPages

Application Migration vs. XPage enablement


In a recent customer discussion a claim was made: " If Notes client application don't automagically can be converted into XPages applications, then we very well can migrate to another platform, it is just the same". An interesting claim, I'll subject it to a reality check. In any case it is a good idea to revisit your investment in your existing applications first.

XPages Enablement

Gradual availability of new functions
  • A reasonable estimate for the required effort is up to 30% of the initial effort. It very much depends on the quality of the existing applications and familiarity and skills of your team
  • There is no data migration, so existing users using a Notes client can continue to use the application until you retire the Notes clients
  • You can look at your application from a functionality and user perspective. A typical first XPages application is an approval module that spans across all your existing applications and provides a single view into anything that needs approval. A next level is forms and tools for mobile personell
  • Domino's security model works in XPages too, so no changes are required
  • If a function in an XPage shows a bug, it doesn't stop executing the function, since a user can fall back to a Notes client until the bug is fixed
  • Mail notifications just work, it's Domino. Also you can build Attention Central
So in a nutshell: low risk, incremental availability, no data migration, freedom to innovate

Read more

Posted by on 01 December 2014 | Comments (3) | categories: XPages

Poking around the iNotes HTTP API (Part 3) - retrieve message meta data


So far we learned about the URLs, how to retrieve the Outline that contains folders and views and how to utilize JavaScript to deal with an API tha hadn't been designed for language neutral access. This part will deal with the retrieval of messages. There are quite some formats, strategies and tweaks to consider:
  • A message consists of headers (fields), and message parts that can be plain text, HTML, embedded images, attachments or other stuff (like the JSON used for embedded experiences). When to retrieve what part is an excellent question
  • Depending on your use case, your final client might or might not have access to the original iNotes implementation (Firewall, Offline, VPN), so just showing the HTML and let it fetch missing pieces might not do the trick
  • The HTML retrieved might not be well formed or contain links you don't want to execute (tracker images, tracker CSS, JavaScript stuff)
  • Automatically retrieving the whole message can be network heavy if there are large images or attachments in the MIME parts, this needs to be planned carefully
  • iNotes allows to retrieve the message fields as (kind-of) JSON using l_JSVars or retrieve the MIME headers using l_MailMessageHeader
  • The content of the message is accessible via s_MailMemoReadBodyContent or UNID/Body?OpenField or l_MailMessageHeader&PresetFields=FullMessage;1 (as raw Mime)
  • The MIME parts retrieved come infested with <br /> tags, since iNotes renders them in a display window (I would have used <pre>, but that's a different story. So they need cleanup
To begin I'll use the result of l_JSVars to learn about the document. Since, again, it is JavaScript, not JSON, I'll take the Rhino approach to extract a Java object.
The parts I'm interested in is in the variable named DXX which contains item that is a representation of NotesItems. True to the nature of an item, the JSON is quite elaborate, which you can see on the example of the form item:
{ "@name": "Form",
  "textlist": {
    "text": [
        {"0": "Memo"}
       ]
   }
}

For our purposes this will be flattened into a Map that has the item name as key. The Java code is quite similar to the retrieval of the Outline, the magic is in the JavaScript:
public MessageObject(String code, String rawMsg) {
    long start = System.currentTimeMillis();
    ScriptEngine engine = new ScriptEngineManager().getEngineByExtension("js");
    engine.eval(code);
    Invocable jsFunc = (Invocable) engine;
    MessageObject msg = (MessageObject) jsFunc.invokeFunction("getMessageObject", rawMsg);
    long end = System.currentTimeMillis();
    System.out.println(msg.getUNID());
    System.out.print("Time in ms:");
    System.out.println(end-start);
    return msg;
}

A little detail to stumble over is the item structure. It can be textlist/text or only text (feels like MIME Headers) and datetimelist/datetimepair/datetime or datetimelist/datetime.

Read more

Posted by on 01 December 2014 | Comments (0) | categories: IBM Notes