Editor's Note: The code in this article includes English and German abbreviations (forwards and replies). Modify the code as needed.
In a long email thread, you may find more Fw:'s and Re:'s than actual words in the subject line, making it difficult to find the email's subject. You may also find that you're unable to locate related messages sorting by subject. To make reading easier, you can use the information in this article to strip away prefixes, such as Fw: and Re:, to create cleaner subject lines. In this article, we describe how to implement this solution in two parts. First, you create a private view based on the All Documents view that includes an extra column for the stripped subject. You use this field to sort your email messages. It contains a rule for stripping away the excess text from your subject lines. Second, you create a SmartIcon that determines the subject line of a currently open or selected email message. The SmartIcon computes a clean version of the subject line using the rules defined for the private view.
This article assumes that you have some familiarity with the Notes Formula Language; however, experience with the Formula Language isn't required.
The private view displays messages whose subject lines have been cleaned up to display the original subject. To create the private view, follow these steps.
- In the Notes client, open your Inbox.
- Choose Create - View.
Figure 1. Create View dialog box
- Enter a view name.
- In the View type field, select Private.
- Keep the default All documents for the Copy style from field.
- Click the Customize button.
Figure 2. Programmer's Pane
- Right-click the Subject column and select Copy from the menu.
- Right-click the column again and select Paste to create a second column labeled Subject.
- Right-click the second Subject column, and select Column - Properties.
- In the first tab of the Column Properties box, enter a new title for the column, such as Stripped Subject.
Figure 3. Column Properties box
- Select the Sort tab in the properties box and specify the following values:
- Sort: Ascending
- Type: Standard
Figure 4. Column Properties box
NOTE: For all other columns in the new view, make sure that the Sort property is set to None.
- Close the properties box.
- In the Objects pane, select the "Stripped Subject (Column)" object. The formula for the Column Value is displayed in the programmer's pane. Replace the default formula:
@If(Form = "NonDelivery Report"; "DELIVERY FAILURE: " + FailureReason; Form = "Delivery Report"; _ "DELIVERED: " + Subject; Form = "Return Receipt"; "RECEIVED: " + Subject; Form = "ReturnNonReceipt"; _ "NOT RECEIVED: " + Subject; Subject)
with the following formula:
shortsubject:=Subject; @If(@Contains(shortsubject; "Re:"); @Set("shortsubject"; @RightBack(shortsubject; "Re:"));""); @If(@Contains(shortsubject; "RE:"); @Set("shortsubject"; @RightBack(shortsubject; "RE:"));""); @If(@Contains(shortsubject; "Antwort:"); @Set("shortsubject"; @RightBack(shortsubject; "Antwort:"));""); @If(@Contains(shortsubject; "AW:"); @Set("shortsubject"; @RightBack(shortsubject; "AW:"));""); @If(@Contains(shortsubject; "WG:"); @Set("shortsubject"; @RightBack(shortsubject; "WG:"));""); @If(@Contains(shortsubject; "Fwd:"); @Set("shortsubject"; @RightBack(shortsubject; "Fwd:"));""); @If(@Contains(shortsubject; "Fw:"); @Set("shortsubject"; @RightBack(shortsubject; "Fw:"));""); @If(@Contains(shortsubject; "FW:"); @Set("shortsubject"; @RightBack(shortsubject; "FW:"));""); @If(@Contains(shortsubject; "Wtr:"); @Set("shortsubject"; @RightBack(shortsubject; "Wtr:"));""); REM "remove leading, trailing, and dup blanks:"; @Set("shortsubject"; @Trim(shortsubject)); @If(Form = "NonDelivery Report"; "DELIVERY FAILURE: " + FailureReason; _ Form = "Delivery Report"; "DELIVERED: " + Subject; Form = "Return Receipt"; _ "RECEIVED: " + Subject; Form = "ReturnNonReceipt"; "NOT RECEIVED: " + _ Subject; shortsubject)
- Save the formula.
- Save and close your new view.
Tip: To change the formula later on, open the view and choose Actions - View Options - Design.
Creating the SmartIcon or customizing your toolbar
This section explains how to create a SmartIcon in Notes 5.0.x, and how to customize your toolbar in Notes 6.0 or later.
The code for the SmartIcon is identical to the code for the private view. The SmartIcon opens the private view, so you can easily see your messages with clean subject lines.
To create a SmartIcon in Notes 5.0.x, follow these steps:
- Open your mail database, and choose File - Preferences - SmartIcon Settings.
- Select an icon of your choice. Generally, any icon not already in use is labeled a Macro Button.
- Drag the icon from the left window to the right window.
- Click the Edit Icon button.
- In the Description field, enter a name for your icon, such as Show mail thread. This name appears when your mouse hovers over the icon.
- Add the following formula to the icon:
shortsubject:=Subject; @If(@Contains(shortsubject; "Re:"); @Set("shortsubject"; @RightBack(shortsubject; "Re:"));""); @If(@Contains(shortsubject; "RE:"); @Set("shortsubject"; @RightBack(shortsubject; "RE:"));""); @If(@Contains(shortsubject; "Antwort:"); @Set("shortsubject"; @RightBack(shortsubject; "Antwort:"));""); @If(@Contains(shortsubject; "AW:"); @Set("shortsubject"; @RightBack(shortsubject; "AW:"));""); @If(@Contains(shortsubject; "WG:"); @Set("shortsubject"; @RightBack(shortsubject; "WG:"));""); @If(@Contains(shortsubject; "Fwd:"); @Set("shortsubject"; @RightBack(shortsubject; "Fwd:"));""); @If(@Contains(shortsubject; "Fw:"); @Set("shortsubject"; @RightBack(shortsubject; "Fw:"));""); @If(@Contains(shortsubject; "FW:"); @Set("shortsubject"; @RightBack(shortsubject; "FW:"));""); @If(@Contains(shortsubject; "Wtr:"); @Set("shortsubject"; @RightBack(shortsubject; "Wtr:"));""); REM "remove leading, trailing, and dup blanks:"; @Set("shortsubject"; @Trim(shortsubject)); @Command([OpenView];"ZZZ View"; shortsubject)
Replace the "ZZZ View" in the last line of the formula with your view name.
- Click OK after adding the formula.
- Click Done in the dialog box.
- Click OK to save the icon.
To customize your toolbar in Notes 6 and later, follow these steps:
- Open your mail database, and choose File - Preferences - Toolbar Preferences.
- In the Toolbar Preferences dialog box, click the Customize tab.
Figure 5. Toolbar Preferences dialog box
- Click New, then select Button.
- In the Edit Toolbar Button dialog box, enter a name for the button along with the pop-up help text.
- In the Formula window, add the code above for the SmartIcon.
- Optionally, click the Change Icon button to select a new icon graphic.
- Click OK when done.
- Click OK in the Toolbar Preferences dialog box to save the new icon.
Using the SmartIcon and private view
Any time you want to clean up your subject line, select or open the email message that you want to change, and then click the new SmartIcon. This action opens your private view where documents are sorted by the cleaned up subject lines. Emails with the same subject lines are sorted by date. The view shows the oldest document with the subject line first and all others documents following.
NOTE: Messages in your Inbox are not affected by the SmartIcon.
First, let's look at the code that computes the value of the additional column Stripped Subject. This code copies the subject of your message to a temporary variable. In a set of operations, this temporary variable is checked for a certain set of prefixes that we want to clean away (for example, Fwd:, Re:, and so on). If found, the prefix is pruned away.
Because the Notes Formula Language does not offer an explicit loop construct, the code looks for the rightmost Re: and anything before the Re: is pruned away. This may prune away too much in certain cases. To illustrate that, let's consider the following artificial subject line:
You are selected for a Corporate Award, but you have to respond immediately Re: by today
In this case, the formula cleans the subject line and removes all text before “by today." The risk of removing too much of the subject line is low, however, because several messages with this subject are still sorted together in the "by today" group of emails. If the resulting stripped subject line is empty, a message is shown together with all other emails without a subject line. If you do not want to take this risk, you can add code that removes only the substring instead.
To remove up to any number of occurrences of the same subject, repeat the check for the substring as many times as you think is sufficient. If you want to check for and remove up to three occurrences of Fwd:, then the fourth occurrence of the prefix remains in the subject line. On the other hand, if you perform this check four times or more for each of these prefixes, this feature may consume more computer resources than necessary.
Let's consider the same code that computes the temporary stripped subject in the SmartIcon code. The stripped subject line computed here is key when opening your private view. You may have noticed that the code is duplicated here again with the disadvantage that any changes (for example, adding another string that should be ignored) have to be made in two places. You may want to consolidate this using shared code available in Notes 6 and later. At the risk of making the code slightly more difficult to understand, the benefit is easier maintenance because it is really important that the code in the two places be identical. (If not, the stripped subject line in the view and the computed key value for entering your private view would not match, resulting in an error message.)
Comparison with the Discussion Threads view
You may be familiar with the discussion threads view, and you may wonder whether or not the stripped subject line solution offers any advantage over that view: The answer is yes. In fact, there are two distinct advantages that the stripped subject line solution has over the discussion threads view.
The first advantage is that the stripped subject line can identify and merge threads even if some of the involved parties used Forward or even Forward without attachment instead of Reply or Reply with History. The discussion threads view loses the connection between mail documents when some are created by Forward or by Forward without attachment.
A second advantage involves dynamic sorting done by clicking the twistie in the column headers. In this situation, the stripped subject line solution allows you to re-sort documents, while keeping the current document in focus, which is difficult for the discussion threads view.
This article shows you two things:
- How to get a complete list of messages with the same subject, while ignoring the well known prefixes added during the Reply and Forward operations or by a confidential flag. This task is done only by sort order, without affecting the subject line, so the full information remains intact.
- It shows you how to display a complete list of messages with a single click, while editing a mail document or while having one document selected when working with your Inbox.
As you can see by the small amount of coding needed, this is just one more example of the powerful Notes infrastructure that allows a high amount of customization at low cost.
- For information about how to create a Notes agent to help you prioritize your messages, see the article, "Creating an Inbox Assistant."
- For tips on enhancing Notes mail, see the following:
- Marking incoming mail
- Creating the "Mark unsigned mail with attachment" agent
- Show original size of a truncated document
- Issue a warning before sending an unsigned mail with an attachment
- Make Notes warn you before sending a mail with an empty subject line




