Creating email content in NPrinting

I thought quite long about what my next tip re NPrinting development will be. Going through different topics on Qlik Community few times I bumped into a question: “How to style NPrinting email content?”. This seems to be straight forward question and answer is almost at the tip of the tonque as NPrinting provides out of the box mail content editor under publish task options, BUT…. is it really so straight forward?

I – Scenario

When you create an email message in NPrinting publish task editor you have few available options:

  1. Format – you have choice of using HTML or Text
    • Since we are interested in well formatted output this option stays on HTML
  2. </> This button allows you to toggle between HTML and Rich Text. I played with Rich text option and tried to use inline styles to build my well formatted message. I stumbled into a small problem when trying to format/scale fonts and images. It never rendered as I wanted it to per my inline styles so i quickly gave up

Above 2 are all what you can really do directly in built-in message editor. If this is enough for you, then you are a Happy Camper! It wasn’t for me. So how did i went about my NPrinting email message?

II – Create HTML Report Template.

I needed well formatted HTML email content. To achieve this I had to build it and then embed it in email body. NPrinting does not allow to embed external files directly in email content editor, however it allows to embed HTML NPrinting reports. My solution is based on this approach. I have created my email content and I am almost ready to embed it. The last bit I need to do is to include some branding (logos/images).

undefined

Above shows that I have placeholders ready for images to be placed in. How can I place them in? One option is to use images coming from QlikView or Qlik Sense. This approach is easy and allows any image from Qlik application to be put in your template. My approach however is different. I prefer to encode images as base64 codes and put them directly as “data:image/png;base64,iVBO….etc” code. This allows me to retain logos and images transparencies which is a big benefit and helps to create professionally looking content. Base64 code is usually very long hashed text. To avoid clatter in template I put it in NPrinting formula as =’here I put my base64 reference’ and reference formula in template.

Note how i include “=” sign to evaluate base64 string as text

If you want to create more dynamic content for example images dependent on selections (for example departments logos) you can create individual variables for each log/image and then use another variable to conditionally reference variable with correct base64 image.

III – Embed report in email body

After adding images to my email content HTML template I am happy to embed it in the email body. To do this I need to add my report to publish task as HTML output format, uncheck “Attach to email”. Then go to “Email message” section where you need to click on “Reports” tag –> “embed reports” –> and select Html report to be your email content. You also want to only select chosen attachments so under the email body content toggle “Attachments” change drop-down to “Selected attachments” and choose which ones need to be physically attached.

This concludes my thoughts around email formatting topic.

Benefits:

  • By creating such template you can deliver standardised content to your recipients
  • Re-usability: less development when you create new report and need new email message

Possible improvements (topics for another post)

  • Examples of base64 codes in variables dynamically producing image based on selected filters
  • Dynamic content of email body (different approach with single app supporting multiple NPrinting reports and tasks)

Limitations:

  • It will be quite difficult (or in some scenarios impossible) to include in the email content dynamic user names
  • For each NPrinting app/report you need to create dedicated template or spend time designing Qlik app supporting all your reports and dynamically changing text based on filters applied during NPrinting task execution.

Resources:

  • Here is a short video showing how to use base64 encoding: Link
  • This topic relates also closely to this community post

As always I am looking forward to your comments.

Cheers!

2 Comments

    1. Hi Jes,

      What source code are you referring to? There is no actual code relevant to the topic I have described, only the way I use base64 images embedded in NPrinting variables or functions. The actual html is not something I can share but regardless it would not be relevant anyway…

      Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s