Quantcast
Channel: ibm | Johno's Workbench
Viewing all articles
Browse latest Browse all 24

IBM Domino Tip: Pass HTML to RichTextItem without using MIMEEntity

$
0
0

Notes8_9Logo

This is a quick tip on how to include HTML when populating a RichTextItem object without using MIMEEntity in IBM Notes/Domino.

First some venting

It’s amazing how certain easter egg features have been available in the Domino Object Model since release 5, that I’ve managed to keep missing, yet constantly required. This morning I happened to stumble across one of them.

For the longest time, whenever I needed to send out a mail programatically via code that needed even the slightest bit of HTML, I would resort to using a MIMEEntity object. Which is great don’t get me wrong, but most of the time it’s actually overkill. This morning, all I wanted to do in my RichTextItem is include a URL (Not a doclink, but a predefined URL). I would do this by using:

RichTextItem.appendText("www.ukuvuma.co.za");

This was never an issue for me back in the day because, in IBM Notes Mail, Notes would see it as a url and convert it into a hyperlink. In my particular case when testing with Gmail and Outlook, the url just showed as plain text and nothing more. “Oh crap!” are the words I believe I used this morning. I kept thinking…”here we go again with MIMEEntity“.

Thankfully, I took a minute to double check the Designer Help. At first I noticed that there were no real options for me in the RichTextItem object, but when taking a look at the RichTextStyle object (this is used to provide standard font changes, etc. in your RichTextItem), I noticed what is right now to me the most beautiful object property of the year….PassThruHTML!!!

The Solution

Using my example above, assuming you have a RichTextStyle object initiated, all I needed to do was the following:

RichTextStyle.setPassThruHTML(true);
RichTextItem.appendStyle(RichTextStyle);
RichTextItem.appendText("<a href="www.ukuvuma.co.za">www.ukuvuma.co.za</a>");
RichTextStyle.setPassThruHTML(false);
RichTextItem.appendStyle(RichTextStyle);

That’s it. Domino converts the text into HTML and applies it to your RichTextItem object. I’ve spent the day kicking myself for not seeing this before, but I think I’m over it now. As long as this blog post can help others early enough from following the same road I travelled.

Till next time :)

John

The post IBM Domino Tip: Pass HTML to RichTextItem without using MIMEEntity appeared first on Johnno's Workbench.


Viewing all articles
Browse latest Browse all 24

Trending Articles