Reg Exp
Web Design
Notes Client
Trapping Messages Marked Return Receipt
This week, we have another guest tip from Alain Romedenne (aromedenne at amadeus dot net). Alain is heavily involved with the OpenDOM and NSFPeek projects at OpenNTF.org, and wanted to share some of his wisdom with the Breaking Par readers. Thanks, Alain! This tip talks about adding color coding in your mail file for messages that are marked "Return Receipt".

In a Notes mail message, you can set all kinds of delivery options. One of the options is "Return Receipt". If this setting is enabled on a message you send, you will receive an email back when the recipient opens the message. The only way the recipient knows about the "return receipt" setting is after the fact when they see "return receipt submitted for delivery" in their status bar. With this tip, you can identify messages that have this setting enabled.

First, let me point out a couple things. Number 1 is that an agent is being added to the mail file. Since it is only an agent and we're not modifying anything else from the out-of-the box template, this should not be too big of a deal. But you'll want to check with your individual support contracts before deploying this on a wide scale. Number 2 is that this tip is defeating the purpose of the return reciept setting. In certain circumstances, return receipt may be desired. You'll want to check with your company's policies (if there are any) on return receipt.

The first thing you want to do is create an agent in your mail file. This agent will run on newly received messages. The trigger for the agent is "before new mail arrives". Call the agent whatever you want, but name it something easy enough so you can identify it later. The agent will be a formula-based agent, and it will change the email's "from" or "principal" value in a way we can identify through color later.

hasReturnReceipt := @IsAvailable(ReturnReceipt) & ReturnReceipt = CONFIRM_READING;
@If(hasReturnReceipt; ""; @Return(""));
isInternetMail := (PRINCIPAL = "");
" On Return Receipt, tag sender name with '' (Registered sign) or '' (No-Break Space) chars ";
TAG := "";
NBS := "";
DELIM := "/";
newSender := @If(isInternetMail; @ReplaceSubstring(From; "@" : " "; TAG : NBS); @ReplaceSubstring(@Name([CN]; PRINCIPAL); " "; NBS) + DELIM + @Name([HierarchyOnly]; PRINCIPAL));
" Post-conditions ";
@If(isInternetMail; @SetField("From"; newSender); @SetField("PRINCIPAL"; newSender));

The code is commented and fairly self-explanatory. It is finding messages that have the field ReturnReceipt equal to the text value "1". Once it finds those messages, the From or Principal is modified. The key is how the field is modified. If there is an "@" character, it is replaced with the "" character. When you're building the agent, the easiest way to write the "" character is to use the side numeric keypad on your keyboard. You can hold down the ALT key and then type 0174 and release the ALT key. The character will appear. If you don't have the side numeric keypad, then you can use the Windows character map program to find the character.

The NBS variable in the agent is a non-breaking space character. So, in the fields, a regular space character is replaced with a non-breaking space character. This character is not character 32 - that's the regular space character. If you have a numeric keypad, the character can be created by holding down the ALT key and typing 0160 and releasing the ALT key. It can also be found on the Windows character map - just make sure you're not using the regular space character.

With the From or Principal fields being fundamentally changed, any return receipt sent back to the address will no longer work. So, technically, you don't have to worry about the ReturnReceipt field value. You do have to worry about the field value if you want to reply to the person, however.

Now that the field (either From or Principal) has been updated, we can highlight messages that have return receipt through features built-in to the standard mail template. To do this, go into your mail file preferences, and choose the Colors tab, as seen in figure 1. You can color-code messages (both the foreground and background colors can be set) that are from a particular user or you can use a partial name, which we do here. Each partial name goes on its own line inside the field. On the first line, we have our "" character. On the second line, we have our non-breaking space character. For either of those partial matches, the background color is set.

With that setting, the Inbox folder now magically uses that color for the documents with a return receipt, as seen in figure 2. So, by only writing a new agent, and by using additional features that are standard in the mail file, we can easily identify and "disable" messages with return receipt set.