0

I often use two gmail labels label1 and label2, and according to my personal mail management rules, I often change messages categories from label1 to label2.
As I do this often, I thought I should try to automatize this process a bit by adding custom gmail command.
Here are the specifications of my mini-feature :

1) When a message (according to gmail api, a "thread") labelled label1 is selected in gmail, a button "CHANGE LABEL1 TO LABEL2" should be displayed in my gmail interface
2) When I click this button, selected message's label1 should be removed, while a label2 label would be added

That's it for the features.
Technically, here is what I think is needed :

a) A way to get and set the labels attached to a given message thread (identified by an id)
b) A way to display a button conditionally
c) A way to trigger a script when the button is clicked
d) A way to detect the id of selected message thread

Here are the technical solutions I think are available for each part :

a) ...is possible via a Google Apps Script, using GmailThread::addLabel and GmailThread::removeLabel
b) ...seems possible via a contextual gadget
c) ...is my first concern, since clicking on the button from b) should launch the script from a) Also, the call to the a) script should pass the message thread id as a parameter.
d) ...is my second concern, maybe is it also possible via a contextual gadget, since those can parse the contents of a message ?

Does it seem possible to implement this mini-feature given the actual technology provided by google for scripting ?
More precisely, is it possible to make Gmail Gadgets and Gmail Apps Scripts interact ?
Or are there some alternatives to implement it ?

Additional information : I tried to investigate other technologies provided by Google to customize its product, but it seems that Gmail Labs API is not open to the public. Also, I don't think I could use a Gmail Sidebar Gadget since they do not seem to be able to know which message is currently selected in the gmail interface.

Community
  • 1
  • 1
wip
  • 2,313
  • 5
  • 31
  • 47

2 Answers2

2

I don't know if you can use a contextual gadget this way but you may write a simple script (time triggered) who search for threads with a third label (or one of the stars) used by you as an indicator of your will to toggle labels...

The script search the threads you mark and toggle labels (than remove the mark) ... Pretty easy ...

Edo
  • 1,539
  • 18
  • 26
  • That's a good idea ! I could indeed reserve a star for this purpose (I am not using them yet). The idea of the button was to speed up the process of searching for a label in my long labels list. I might face the same kind of problem if I start to use a lot of different stars though. Also maybe a [gmail style](http://userstyles.org/styles/browse/all/gmail) for the [Stylish plugin](https://chrome.google.com/webstore/detail/fjnbnpbmkenffdnngjfgmeleoegfcffe) could make this star look like a button (complete with caption) ? I think I will try this if there are no other suggestions.. – wip May 16 '12 at 07:55
  • let me know how you solve your problem and if you choice my answer please rate it ;) – Edo May 16 '12 at 09:17
  • Sorry for the late reply. I wanted to try this approach using gmail's star called "green-check", however the call GmailApp.search('has:green-check') does not work. By the way here are the [stackoverflow question](http://stackoverflow.com/questions/10629130/will-a-function-be-added-to-gmail-app-script-api-to-get-the-type-of-star-assigne) and the [Google Apps issue report](http://code.google.com/p/google-apps-script-issues/issues/detail?id=1335) I wrote for this separate problem. – wip Jun 25 '12 at 06:55
1

I do something similar at the moment using a contextual gadget. The only way I know to change the labels is via IMAP. My gadget passes the details of the email to my server which uses IMAP to connect to email message and change its label. Although this seems a long winded way of doing this I think it is your only option.

PaulC
  • 11
  • 1
  • Thanks for the suggestion, it seems more difficult that using Google Apps scripts but I will eventually try it and tell you how it worked. – wip Jun 25 '12 at 06:57
  • So do I need to physically setup a new machine to create that IMAP server or are there some services that will host it (for free ??) – wip Jun 25 '12 at 22:04