# 3.5. Filters

After using KMail for a while, you may find that you have trouble sorting out the new messages in your inbox when they arrive. Filters allow you to automatically perform certain actions on incoming messages and to manually perform actions on selected messages in a folder.

The actions section of the Filter Rules window lets you perform up to eight actions in one filter.

Usually, filters are used on incoming messages, but they can also be applied to a message or group of messages. To selectively filter messages in a message folder, select the messages you want to filter and type Ctrl+J or select Message | Apply Filters. Note that this will apply all of your filters to that message; there is no way to apply only certain filters to a message.

If you ever need to remove a filter, select it from the Filter Rules window and press the Delete button.

## 3.5.1. Filter Examples

If I am subscribed to the KDE User List, I could create a folder for the list (I'll call it KDE-User) and use a filter to automatically transfer new messages from my inbox to my KDE-User folder if they are from the KDE User List. Here is how to create this filter:

1. Think of a unique way of identifying the messages you want to filter. The unique property of my KDE User List messages is that they always contain "kde-user@kde.org" in the To: or Cc: field.

2. Select Filter... from the File menu.

3. Press the New button to create an empty filter.

4. Select the empty filter from the list. (It will appear as Unnamed).

5. The right side of the Filter window contains two sections: matching criteria and actions. In the matching criteria area, select <To: or Cc:> from the first pull-down menu, "Contains" from the second pull-down menu, and type kde-user@kde.org in the text field.

6. Skip down to the actions section. Select "Transfer" from the first pull-down menu. A new pull-down menu containing a list of folders will appear. Select the folder that you want the filtered messages to be transferred to if they match the criteria you selected. For this example, you would select "KDE-User" from the pull-down menu.

You may find that you need to use more complicated criteria to properly filter your messages. For example, you may only want to save the KDE User List messages that are written by your friend Fred Johnson <fj@anywhere.com>. This is where the rest of the matching criteria section comes into play:

1. Open up the Filter Rules window and select the filter you just created.

2. Since you want to filter all messages that have "kde-user@kde.org" in the To: or Cc: field AND that are from Fred, select the AND option from the pull down menu between the two criteria sections.

3. Now, go to the bottom criteria section and select the following from the pull-down menus: "From:", "Contains". Now, type fj@anywhere.com in the text field.

You now have a filter that transfers all KDE User List messages that are from Fred Johnson.