Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

I've been using Filters for a while in Gmail but have always been wondering if such a feature is available. Is it possible to somehow have a Gmail filter apply more than one label?

As you can see below, the filter setup page only allows choosing one label:

alt text

If it turns out that it is impossible to specify more than one label, I guess I'll just have to create duplicate filters.

share|improve this question

3 Answers 3

up vote 14 down vote accepted

No, there is no way to do this.

But, you can use the Google Labs project Filter import/export under Settings > Labs in Gmail.

  1. Install Filter import/export in Labs
  2. Create your filter
  3. Go to Settings > Filters
  4. Check the checkbox next to your new filter
  5. Click "export" at the bottom, this will create an xml file called mailFilters.xml
  6. You should have a file that looks like this:


<?xml version='1.0' encoding='UTF-8'?>`
<feed xmlns='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>
    <title>Mail Filters</title>
    <id>tag:mail.google.com,2008:filters:11344473557977</id>
    <updated>2010-07-14T20:24:10Z</updated>
    <author>
        <name>John Smith</name>
        <email>test@gmail.com</email>
    </author>
    <entry>
        <category term='filter'></category>
        <title>Mail Filter</title>
        <id>tag:mail.google.com,2008:filter:1131773557977</id>
        <updated>2010-07-14T20:24:10Z</updated>
        <content></content>
        <apps:property name='from' value='foo@example.com'/>
        <apps:property name='label' value='the_label'/>
    </entry>
</feed>

All you need to do is to carefully edit this XML file in an editor which can intelligently handle plaintext.

Copy the code from <entry> and paste it in immediately after the first one. I removed the <id> and <updated> sections and they still worked, so much of the stuff in there is optional. Copy and paste a few more times, and you've got the result you want.

This worked for me:

<?xml version='1.0' encoding='UTF-8'?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:apps='http://schemas.google.com/apps/2006'>
    <title>Mail Filters</title>
    <id>tag:mail.google.com,2008:filters:11344473557977</id>
    <updated>2010-07-14T20:24:10Z</updated>
    <author>
        <name>John Smith</name>
        <email>test@gmail.com</email>
    </author>
    <entry>
        <category term='filter'></category>
        <title>Mail Filter</title>
        <id>tag:mail.google.com,2008:filter:1131773557977</id>
        <updated>2010-07-14T20:24:10Z</updated>
        <content></content>
        <apps:property name='from' value='foo@example.com'/>
        <apps:property name='label' value='the_label'/>
    </entry>
    <entry>
        <category term='filter'></category>
        <title>Mail Filter</title>
        <content></content>
        <apps:property name='from' value='bar@example.com'/>
        <apps:property name='label' value='another_label'/>
    </entry>
</feed>

Save your file then use the Import tool on the same Settings > Filters page and you will have the option of which of the contained filters you want to add.

share|improve this answer
3  
It's the long way round to making 2 or more filters with the same rule that apply different labels. A shortcut because you can't do what the OP asked. –  artlung Jul 15 '10 at 9:01
2  
Excellent - I have about 200 filters which apply labels, and I wanted to edit them all to add an additional label, and there's no way I was going to create another 200. Now I can just write something (maybe just an emacs macro) to duplicate the existing ones and add the new label. Thanks! –  Jer Jan 8 '13 at 15:17
    
@Jer glad this 2-1/2 year old post could help! If you end up writing any tools to facilitate this or have other tips feel free to edit my question or add your findings as a comment here! –  artlung Jan 8 '13 at 19:17

According to this Google Groups post, it is not possible:

Unfortunately, a filter can only apply a single label. If you want to apply more than one you need to create more than one filter, with the same search criteria.

share|improve this answer

The post from artlung has the right idea (the easiest way to do this is to edit the filters as XML), but the XML code he posts actually does not do what the original poster requested. The original poster requested to have a single filter that applied two different labels. That is, the original poster wanted to apply two labels to the same email message, identified by the same criteria. (This requirement is implicit in his screenshot showing the "one label" limitation in Gmail after you have selected a set of filtering criteria. It is also what I happened to need today.) The post by artlung applies the_label to messages from foo@example.com and another_label to messages from bar@example.com. In other words, it applies one label to messages from one person and a different label to messages from another person. The requirement is really to apply both labels to messages from the same person.

You might think that code like this would work:

<entry>
    <category term='filter'></category>
    <title>Mail Filter</title>
    <content></content>
    <apps:property name='from' value='foo@example.com'/>
    <apps:property name='label' value='the_label'/>
    <apps:property name='label' value='another_label'/>
</entry>

But you would be mistaken. When you import XML like that above into Gmail, the first label assignment (the_label) will be silently dropped, and you will wind up with a filter that only assigns another_label. You have to do as artlung suggests and have two separate blocks. However, to get the intended effect, the two blocks would need to have the same trigger (matching criterion), like this:

<entry>
    <category term='filter'></category>
    <title>Mail Filter</title>
    <content></content>
    <apps:property name='from' value='foo@example.com'/>
    <apps:property name='label' value='the_label'/>
</entry>
<entry>
    <category term='filter'></category>
    <title>Mail Filter</title>
    <content></content>
    <apps:property name='from' value='foo@example.com'/>
    <apps:property name='label' value='another_label'/>
</entry>

Perhaps this much is obvious and implicit in artlung's answer. The main piece of new information I am adding is that the "two labels in one filter" solution does not work, even in XML. I tested it, and as I noted, you only get the second label. I would have posted this as a comment, but I don't have the rep.

share|improve this answer

protected by Community Jul 12 at 18:19

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.