Take the 2-minute tour ×
Android Enthusiasts Stack Exchange is a question and answer site for enthusiasts and power users of the Android operating system. It's 100% free, no registration required.

The most recent version of the Gmail app as the great feature where you can choose between archiving or replying to e-mails directly from the notification.

My problem is that, if you archive it from the notification, it remains unread (instead of being marked as read). Is there anyway to get around that?

I'd like for any e-mails that are archived directly from the notification to be automatically marked as read.

share|improve this question
1  
I don't believe that is currently possible. The only action you can change it to is to delete instead of archive. –  Al E. May 7 '13 at 12:53
    
@AlEverett I was hoping there might be way to do it with an alternative app, or at least a google script. =/ –  Bruce Connor May 7 '13 at 13:53

3 Answers 3

up vote 3 down vote accepted

Did you say Google Script?

Marking Gmail read with Apps Script

The idea behind this script is to mark as read any message that is not in the Inbox (i.e., has been archived).

  1. Head to script.google.com to start a script.
  2. Choose to create a script for Gmail in the little popup.
  3. Delete all the sample code it gives you.
  4. Replace it with this (written using the API reference):

    function markArchivedAsRead() {
       var threads = GmailApp.search('label:unread -label:inbox');
       GmailApp.markThreadsRead(threads);
     };
  5. Save the project with File > Save.

  6. Add a new version using File > Manage Versions and enter "initial version" then submit that.
  7. Do a test run using Run > markArchivedAsRead and be sure and authorize the app when it asks you to.
  8. Add a new trigger using Resource > Current Project's Triggers and choose to run the above function every minute.
  9. Save the script again and exit.

I don't know that it's necessary to run it every minute, but as long as you run it regularly.

This isn't a direct answer to your issue, and if you have reasons to have unread messages that aren't in your inbox this won't work for you.

share|improve this answer
    
I do have some filters which might directly archive unread e-mails, and I'd like to keep those unread, but that's a really good start. I could have a second script that marks with a specific label the unread threads in my inbox. And then this first script would only mark-as-read archived messages with this label (instead of all archived messages). –  Bruce Connor May 13 '13 at 11:14
2  
This also has a slight bug. If you archive a message and a new message arrives on the same thread before the script has a chance to run, then both of them will get marked as read when the script does run. That's because GmailApp.search returns entire threads, and doesn't care if one of the messages in the thread was in the inbox. –  Bruce Connor May 13 '13 at 21:24

I managed to make it work with the following Google Script.
It's almos the same as @AlEverett's answer, but it never marks as read messages that skipped the inbox entirely (from a filter or something).

Unfortunately, it won't work for you if you tend archive messages very quickly (less then 30 seconds on average).

/** Mark as read archived threads which were previously in the inbox (determined by the label "i"). **/
function cleanAndroidArchived(){
  markArchivedAsRead();
  labelInboxAsI();
}

function markArchivedAsRead() {
  var threads = GmailApp.search('in:unread label:i -label:inbox');
  var label = GmailApp.createLabel("i");
  label.removeFromThreads(threads);
  GmailApp.markThreadsRead(threads);
};

function labelInboxAsI() {
  var threads = GmailApp.search('in:unread label:inbox');
  var label = GmailApp.createLabel("i");
  label.addToThreads(threads);
};
share|improve this answer

I believe I resolved the issue with @BruceConnor's case, needing to wait for the script to execute before it can work.

  1. I created a new filter that looks for anything in the inbox
  2. assigns the "i" label (which is created by his version)

Gmail complains that the filter will never match anything, but in this case it does match all incoming messages that stay in the inbox.

The result is that all new incoming messages are automatically "memorized" by this tag, then when you hit archive the script can compare the inbox list with the "i" label and know which ones were just archived, and then mark only those as "read". You don't have to wait to archive, because all messages are assigned into the archive "i" queue.

Bonus: I also set the new "i" label to "Hide in message list" and "Hide in label list", so it never shows up at all. (Click the little arrow next to the new "i" label and choose these options.)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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