I want to create a filter for all email sent by me only to me.
I do that because when I have a note that I want to remember, I send it to myself. I want to label all those notes so I can find them easily.
Web Applications Stack Exchange is a question and answer site for power users of web applications. It only takes a minute to sign up.
Sign up to join this communityTo search for email sent only to you and not to a mailing list, for example, you have to add the following to the search box (and then you can create a filter using that search; there is a link in the expanded search box that says "Create filter >>" or something):
To:me AND -*
This means it'll search for email sent to "me" (that's you) and not to everybody else (including you) (that's *
), but the first part (i.e., To:me
) overrides that.
This new answer works if one of the other recipients has a top level domain that is common-ish and different from yours.
Aaron's answer appears not to work, for two reasons. The first is that google does not implement wild cards in gmail (Wildcard search in Gmail).
The second reason is that, from experience, I find the search considers BOTH conjuncts, to:me
and, say, -to:com
. It's easy to check by entering to:me -to:com
in the search bar, and finding that nothing sent to your gmail.com address is there.
From the question I linked above we know that you need to search tokens; e.g., top level domains like .com and .org. But we know we can't just do
to:me to:(-com -org -edu -gov -uk -net -ca -de -jp -fr -au -us -ru -ch -it -nl -se -no -es -mil)
As an aside, don't try and putting ALL top level domains in, as the search will be rejected for length. I got the above list from This blog post about common TLDs.
There is one more thing to deal with, and that is the empty to:
field. My work around is to use is:important
to limit the intrusion of these. Gmail complained when I tried to make a filter with this flag, but it did properly filter a new (important) email to me.
So, we come to my answer, where my own top level domains are .com and .uk (.ac.uk, but the .uk is a token in itself):
is:important to:((-com OR me) -coop -org -edu -gov (-uk OR me) -net -ca -de -jp -fr -au -us -ru -ch -it -nl -se -no -es -mil)
This enforces the following two properties: 1. Emails to anyone with a listed domain different from yours are rejected 2. If an email has one of your domains, it must be (at least) to you.
In a similar manner, you can add specific email addresses that you commonly receive email together with you by adding something like -<[email protected]>
In the To
field, use me -*
. This could also be broken out in the other fields with to:me to:-*
.
Here's a thread on Google's help forum..
to:me
part, but it doesn't seem like the -*
part does anything (i.e. I get the same results with and without it). Does it show different results for you?
to:me -to:*
. However, the search doesn't seem to exclude messages sent to a list of addresses.
to:me to:-*
and to:me -to:*
seem to give me the same results.
Aug 3, 2010 at 0:10
Try replacing -*
with a couple of common email addresses in the heavy emailers list. something like this might work to:(me -*@aol.com)
When creating the filter, can you put your email address in the from field and in the to field. I just tried this and it only includes emails that I've sent to myself.
Here is some of the help on Gmail's search (somewhat unrelated): http://mail.google.com/support/bin/answer.py?hl=en&answer=6593
Since we're talking about Gmail...
I use a lesser known feature of Gmail combined with a filter to accomplish this:
The feature is that Gmail (personal) supports any number of .
in the address.
So if my email address is [email protected]
then sending mail to all of the following permutations (and many more) will still go to [email protected]
e.g.
[email protected]
j.oh[email protected]
[email protected]
[email protected]
You get the idea.
Your request:
I want to create a filter for all email sent by me only to me.
To accomplish this I send all these "notes" to a permutation that I know no one else uses. E.g. [email protected]
The filter I set up is very simple after that
To:[email protected]
Note: I also use this trick to filter email when signing up for questionable sites by signing up with a permutation I can filter straight to trash
You'll note from the blog that there is a similar Gmail feature that is more straightforward. I could use `[email protected]' and now the filter is obvious and easier to remember.
To sum up:
[email protected]
to:
filters for these special alias permutationsMy solution:
it's simple......
create a filter like this, click on the arrow for the advanced search options
You will reveal the advanced search features, type from:[email protected] in the "includes the words" field and click "create filter with this search". You will have to create a label when you go to the next screen
follow the prompts and thats it.
I have implemented a solution in Google App Script. Basically, this is very close to the solution proposed by @Christian Krüger.
The pre-requisite is to create the label 'meonly' (I could have done it programmaticaly, but for readability I did not put it below).
Here is the Google App Script code:
function to_me_only()
{
var search = 'to:me -is:chats in:inbox -label:meonly';
try {
var label = GmailApp.getUserLabelByName('meonly');
var threads = GmailApp.search(search);
var gmailMessages = GmailApp.getMessagesForThreads(threads);
for(var i=0; i<threads.length; i++) {
var messagesForThread = gmailMessages[i];
for(var j=0; j<messagesForThread.length; j++) {
var messageTo = messagesForThread[j].getTo()
if( messageTo.toLowerCase()=='"lastname, firstname" <[email protected]>'
|| messageTo.toLowerCase()=='"firstname.lastname" <[email protected]>'
|| messageTo.toLowerCase()=='firstname lastname <[email protected]>'
|| messageTo.toLowerCase()=='[email protected]'
|| messageTo.toLowerCase()=='<[email protected]>'){
threads[i].addLabel(label);
}
}
}
} catch (e) {
console.log('Error');
console.log(e);
}
}
I have then created a trigger to execute the above code every 5 minutes.
I think it should work with below filter in "Includes the word" below line. I have tested this sending mail from other mail ID, and now I am putting same on live filter to check if everything is working fine.
to:[email protected] -{cc:[email protected]}
I gave up on filters but this works:
Select your Sent Mail.
In the search box, enter to: me
.
to:me AND from:me
Works very well.
It can be done by using -> To: me is: important where To is a field you will find it in settings while creating a new filter. No brackets nothing simply write me is: important in To field.(ignore the error & proceed)
Use your complete address after to:
instead of to:me
and you'll get better results.