Skip to main content

By clicking Submit, you agree to the developerWorks terms of use.

The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

All information submitted is secure.

  • Close [x]

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerworks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

By clicking Submit, you agree to the developerWorks terms of use.

All information submitted is secure.

  • Close [x]

Cleaning up your subject lines

Andreas Arning, WebSphere Process Choreographer Development, IBM Corporation
Andreas Arning works on WebSphere Process Choreographer Development.

Summary:  Remove those pesky Fw:'s and Re:'s from your mail messages with the click of a button. This article describes how to create a private view and a SmartIcon that removes prefixes from your mail message subject lines using the Notes formula language.

Date:  12 Jul 2004
Level:  Introductory

Activity:  3595 views
Comments:  

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.

Creating a private view

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.

  1. In the Notes client, open your Inbox.
  2. Choose Create - View.
    Figure 1. Create View dialog box
    Create View dialog box
  3. Enter a view name.
  4. In the View type field, select Private.
  5. Keep the default All documents for the Copy style from field.
  6. Click the Customize button.
    Figure 2. Programmer's Pane
    Programmer's Pane
  7. Right-click the Subject column and select Copy from the menu.
  8. Right-click the column again and select Paste to create a second column labeled Subject.
  9. Right-click the second Subject column, and select Column - Properties.
  10. 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
    Column Properties box
  11. Select the Sort tab in the properties box and specify the following values:
    • Sort: Ascending
    • Type: Standard

    Figure 4. Column Properties box
    Column Properties box

    NOTE: For all other columns in the new view, make sure that the Sort property is set to None.

  12. Close the properties box.
  13. 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)
    

  14. Save the formula.
  15. 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.

Creating the SmartIcon

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:

  1. Open your mail database, and choose File - Preferences - SmartIcon Settings.
  2. Select an icon of your choice. Generally, any icon not already in use is labeled a Macro Button.
  3. Drag the icon from the left window to the right window.
  4. Click the Edit Icon button.
  5. 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.
  6. 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.

  7. Click OK after adding the formula.
  8. Click Done in the dialog box.
  9. Click OK to save the icon.

Customizing your toolbar

To customize your toolbar in Notes 6 and later, follow these steps:

  1. Open your mail database, and choose File - Preferences - Toolbar Preferences.
  2. In the Toolbar Preferences dialog box, click the Customize tab.
    Figure 5. Toolbar Preferences dialog box
    Toolbar Preferences dialog box
  3. Click New, then select Button.
  4. In the Edit Toolbar Button dialog box, enter a name for the button along with the pop-up help text.
  5. In the Formula window, add the code above for the SmartIcon.
  6. Optionally, click the Change Icon button to select a new icon graphic.
  7. Click OK when done.
  8. 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.

The private view code

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.

The SmartIcon code

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.


Conclusion

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.


Resources

About the author

Andreas Arning works on WebSphere Process Choreographer Development.

Report abuse help

Report abuse

Thank you. This entry has been flagged for moderator attention.


Report abuse help

Report abuse

Report abuse submission failed. Please try again later.


developerWorks: Sign in


Need an IBM ID?
Forgot your IBM ID?


Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.

 


The first time you sign into developerWorks, a profile is created for you. Select information in your developerWorks profile is displayed to the public, but you may edit the information at any time. Your first name, last name (unless you choose to hide them), and display name will accompany the content that you post.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.

 


Rate this article

Comments

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Lotus
ArticleID=92550
ArticleTitle=Cleaning up your subject lines
publish-date=07122004
author1-email=
author1-email-cc=

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

For articles in technology zones (such as Java technology, Linux, Open source, XML), Popular tags shows the top tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), Popular tags shows the top tags for just that product zone.

For articles in technology zones (such as Java technology, Linux, Open source, XML), My tags shows your tags for all technology zones. For articles in product zones (such as Info Mgmt, Rational, WebSphere), My tags shows your tags for just that product zone.

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Try IBM PureSystems. No charge.

Special offers