filter that check other mails if positive
-
- Posts: 21
- Joined: May 29th, 2005, 3:16 am
- Location: Wien
- Contact:
filter that check other mails if positive
Hi,
Is it possible either by filtering or with an addon to run the filter on mail to look for a specific subject:
e.g. if subject starts with "Project closed" (the subject contains a number at the end)
and if that subject is found than use the number from that subject and run another filter that marks all mails from the same sender where subject contains that number as read?
Thanks,
Pascal
Is it possible either by filtering or with an addon to run the filter on mail to look for a specific subject:
e.g. if subject starts with "Project closed" (the subject contains a number at the end)
and if that subject is found than use the number from that subject and run another filter that marks all mails from the same sender where subject contains that number as read?
Thanks,
Pascal
-
- Posts: 6429
- Joined: February 3rd, 2009, 6:29 pm
Re: filter that check other mails if positive
I got a two part manual filter working with the FiltaQuilla extension.
http://addons.mozilla.org/thunderbird/a ... ltaquilla/
http://mesquilla.com/extensions/filtaquilla/
http://mesquilla.com/forum/filtaquilla/
http://mesquilla.com/category/extensions/filtaquilla/
http://kb.mozillazine.org/Message_Filters
Remember to check Javascript search term in FiltaQuilla options, then restart.
Filter name: FiltaQuilla Javascript Search Term Part 1 of 2
Javascript:
Filter name: FiltaQuilla Javascript Search Term Part 2 of 2
Javascript:
http://addons.mozilla.org/thunderbird/a ... ltaquilla/
http://mesquilla.com/extensions/filtaquilla/
http://mesquilla.com/forum/filtaquilla/
http://mesquilla.com/category/extensions/filtaquilla/
http://kb.mozillazine.org/Message_Filters
Remember to check Javascript search term in FiltaQuilla options, then restart.
Filter name: FiltaQuilla Javascript Search Term Part 1 of 2
Javascript:
Code: Select all
var win = Services.wm.getMostRecentWindow("mail:3pane");
var uid = "__unique_identifier_FiltaQuilla";
var subject = message.mime2DecodedSubject;
var author = message.mime2DecodedAuthor;
var matches = subject.match(/\d+$/);
if (/^Project closed/.test(subject) && matches) win[uid] = {author: author, project: matches[0]};
(false);
Javascript:
Code: Select all
var win = Services.wm.getMostRecentWindow("mail:3pane");
var uid = "__unique_identifier_FiltaQuilla";
var subject = message.mime2DecodedSubject;
var author = message.mime2DecodedAuthor;
var project = null;
var matches = subject.match(/\d+$/);
if (matches) project = matches[0];
(author == (win[uid] && win[uid].author) && project == (win[uid] && win[uid].project));
-
- Posts: 21
- Joined: May 29th, 2005, 3:16 am
- Location: Wien
- Contact:
Re: filter that check other mails if positive
Hi Morat,
Thanks for the hint. I already use FiltaQuilla for regex filters but am not very proficient in the other capabilities.
Where do I enter the javascript you showed?
Just setting up a new filter and enter it in the field showing up? And with 2 part filter, do you mean with 2 conditions in one filter, or is it 2 separate filters?
regards,
Pascal
Thanks for the hint. I already use FiltaQuilla for regex filters but am not very proficient in the other capabilities.
Where do I enter the javascript you showed?
Just setting up a new filter and enter it in the field showing up? And with 2 part filter, do you mean with 2 conditions in one filter, or is it 2 separate filters?
regards,
Pascal
-
- Posts: 6429
- Joined: February 3rd, 2009, 6:29 pm
Re: filter that check other mails if positive
It works for me with a simple test case. I tagged 2 messages as important in the draft folder.
https://s29.postimg.cc/narc1xvxz/filter1.png
https://s29.postimg.cc/lwzp6mwon/filter2.png
https://s29.postimg.cc/narc1xvxz/filter1.png
There is an "Edit Javascript" button in the Filter Rules dialog.ElPazzo wrote:Where do I enter the javascript you showed?
https://s29.postimg.cc/lwzp6mwon/filter2.png
Last edited by morat on August 21st, 2018, 8:15 am, edited 1 time in total.
-
- Posts: 21
- Joined: May 29th, 2005, 3:16 am
- Location: Wien
- Contact:
Re: filter that check other mails if positive
Thanks,
Yes, found the box when chosing the right option.
So, in fact there are 2 filters.
edit: … for some reason it does not work over here.
filter 1:
filter 2:
I only changed the regex and added condition if mail status unread
Yes, found the box when chosing the right option.
So, in fact there are 2 filters.
edit: … for some reason it does not work over here.
filter 1:
Code: Select all
var win = Services.wm.getMostRecentWindow("mail:3pane");
var uid = "__unique_identifier_FiltaQuilla";
var subject = message.mime2DecodedSubject;
var author = message.mime2DecodedAuthor;
var matches = subject.match(/\b(\d{7}-\d{2})\b$/);
if (/^Projet attribué à un autre prestataire/.test(subject) && matches) win[uid] = {author: author, project: matches[0]};
(false);
Code: Select all
var win = Services.wm.getMostRecentWindow("mail:3pane");
var uid = "__unique_identifier_FiltaQuilla";
var subject = message.mime2DecodedSubject;
var author = message.mime2DecodedAuthor;
var project = null;
var matches = subject.match(/\b(\d{7}-\d{2})\b$/);
if (matches) project = matches[0];
(author == (win[uid] && win[uid].author) && project == (win[uid] && win[uid].project));
-
- Posts: 6429
- Joined: February 3rd, 2009, 6:29 pm
Re: filter that check other mails if positive
I can't really check the regular expressions without knowing the subjects.
The dash could be problem.
e.g. subject uses U+2013 instead of U+002D
Unicode Characters in the 'Punctuation, Dash' Category
http://www.fileformat.info/info/unicode ... d/list.htm
Unicode code converter
http://r12a.github.io/apps/conversion/
Here is how to check the global variable.
1. tools > developer tools > error console
2. paste code in text field
3. press return
Code: Select all
alert("Example 1234567-89".match(/\b(\d{7}-\d{2})\b$/)[0]); // 1234567-89
e.g. subject uses U+2013 instead of U+002D
Unicode Characters in the 'Punctuation, Dash' Category
http://www.fileformat.info/info/unicode ... d/list.htm
Unicode code converter
http://r12a.github.io/apps/conversion/
Here is how to check the global variable.
1. tools > developer tools > error console
2. paste code in text field
3. press return
Code: Select all
JSON.stringify(Services.wm.getMostRecentWindow("mail:3pane"). __unique_identifier_FiltaQuilla);
-
- Posts: 21
- Joined: May 29th, 2005, 3:16 am
- Location: Wien
- Contact:
Re: filter that check other mails if positive
Hi Morat,
examples of subject to be checked first:
Projet attribué à un autre prestataire 1708164-01
if that one is true then mark all mails from that sender containing that number as read:
e.g.
Demande de disponibilité | 1708164-01-03 | DE » fr-FR | Verhaltenskodex
examples of subject to be checked first:
Projet attribué à un autre prestataire 1708164-01
if that one is true then mark all mails from that sender containing that number as read:
e.g.
Demande de disponibilité | 1708164-01-03 | DE » fr-FR | Verhaltenskodex
-
- Posts: 21
- Joined: May 29th, 2005, 3:16 am
- Location: Wien
- Contact:
Re: filter that check other mails if positive
I just managed to check only the first part of the filter by removing the false part at the end.
That one works fine. so it seems it's the second part of the filter (2/2) that generates the problem but I cannot find where.
This is the code I use to match the second part as the number is not at the end here:
That one works fine. so it seems it's the second part of the filter (2/2) that generates the problem but I cannot find where.
This is the code I use to match the second part as the number is not at the end here:
Code: Select all
var win = Services.wm.getMostRecentWindow("mail:3pane");
var uid = "__unique_identifier_FiltaQuilla";
var subject = message.mime2DecodedSubject;
var author = message.mime2DecodedAuthor;
var project = null;
var matches = subject.match(/(\d{7}-\d{2})/);
if (matches) project = matches[0];
(author == (win[uid] && win[uid].author) && project == (win[uid] && win[uid].project));
-
- Posts: 6429
- Joined: February 3rd, 2009, 6:29 pm
Re: filter that check other mails if positive
Is the sender different?
I don't see the problem with the code.
I don't see the problem with the code.
Code: Select all
var s1 = "Projet attribué à un autre prestataire 1708164-01";
var s2 = "Demande de disponibilité | 1708164-01-03 | DE » fr-FR | Verhaltenskodex";
alert(/^Projet attribué à un autre prestataire/.test(s1)); // true
alert(s1.match(/\b(\d{7}-\d{2})\b$/)[0]); // 1708164-01
alert(s2.match(/(\d{7}-\d{2})/)[0]); // 1708164-01
-
- Posts: 6429
- Joined: February 3rd, 2009, 6:29 pm
Re: filter that check other mails if positive
I only store a single project number in the global variable.
http://s27.postimg.cc/ob54j4nkz/filter3.png
That's why the 2 messages with 789 aren't tagged as important.
http://s27.postimg.cc/ob54j4nkz/filter3.png
That's why the 2 messages with 789 aren't tagged as important.
Last edited by morat on August 21st, 2018, 8:15 am, edited 1 time in total.
-
- Posts: 21
- Joined: May 29th, 2005, 3:16 am
- Location: Wien
- Contact:
Re: filter that check other mails if positive
No, it's exactly the same sender. Glad I'm not the only one not seeing any problem with the code.
Yes, it should be only one number per run. But of course it could be that in rare cases there are two rejection mails in the inbox.
But here when testing, there is only one with unread status. So it should only get that one. Or should I rather check for unread status in javascript field instead of adding a second condition for status?
Yes, it should be only one number per run. But of course it could be that in rare cases there are two rejection mails in the inbox.
But here when testing, there is only one with unread status. So it should only get that one. Or should I rather check for unread status in javascript field instead of adding a second condition for status?
-
- Posts: 21
- Joined: May 29th, 2005, 3:16 am
- Location: Wien
- Contact:
Re: filter that check other mails if positive
yes, that seems to be the problem. When I remove the other mails marked as read, it works fine.
How do I check for read/unread status with javascript?
How do I check for read/unread status with javascript?
-
- Posts: 21
- Joined: May 29th, 2005, 3:16 am
- Location: Wien
- Contact:
Re: filter that check other mails if positive
Ok, i found out, by removing the second condition about status adding this to javascript everything works: !(/read/.test(status)) &&
Thanks a lot for your time morat.
Thanks a lot for your time morat.
-
- Posts: 6429
- Joined: February 3rd, 2009, 6:29 pm
Re: filter that check other mails if positive
I got it working by storing all the project numbers in the global variable.
http://s2.postimg.cc/8txcp1i09/filter4.png
Filter name: FiltaQuilla Javascript Search Term Part 1 of 3
Javascript:
Filter name: FiltaQuilla Javascript Search Term Part 2 of 3
Javascript:
Filter name: FiltaQuilla Javascript Search Term Part 3 of 3
Javascript:
http://s2.postimg.cc/8txcp1i09/filter4.png
Filter name: FiltaQuilla Javascript Search Term Part 1 of 3
Javascript:
Code: Select all
var win = Services.wm.getMostRecentWindow("mail:3pane");
var uid = "__unique_identifier_FiltaQuilla";
var subject = message.mime2DecodedSubject;
var author = message.mime2DecodedAuthor;
var project = null;
var matches = subject.match(/\d+$/);
if (matches) project = matches[0];
if (/^Project closed/.test(subject) && matches) {
if (!(uid in win)) win[uid] = [];
var bool = false;
for (var i = 0; i < win[uid].length; i++) {
bool = (author == (win[uid][i] && win[uid][i].author) &&
project == (win[uid][i] && win[uid][i].project));
if (bool) break;
}
if (!bool) win[uid].push({author: author, project: project});
}
(false);
Javascript:
Code: Select all
var win = Services.wm.getMostRecentWindow("mail:3pane");
var uid = "__unique_identifier_FiltaQuilla";
var subject = message.mime2DecodedSubject;
var author = message.mime2DecodedAuthor;
var project = null;
var matches = subject.match(/\d+$/);
if (matches) project = matches[0];
var bool = false;
if (uid in win) {
for (var i = 0; i < win[uid].length; i++) {
bool = (author == (win[uid][i] && win[uid][i].author) &&
project == (win[uid][i] && win[uid][i].project));
if (bool) break;
}
}
(bool);
Javascript:
Code: Select all
var win = Services.wm.getMostRecentWindow("mail:3pane");
var uid = "__unique_identifier_FiltaQuilla";
if (uid in win) delete win[uid];
(false);
Last edited by morat on August 21st, 2018, 8:16 am, edited 2 times in total.
-
- Posts: 6429
- Joined: February 3rd, 2009, 6:29 pm
Re: filter that check other mails if positive
Try these:ElPazzo wrote:How do I check for read/unread status with javascript?
Code: Select all
(message.flags & Components.interfaces.nsMsgMessageFlags.Read);
Code: Select all
(!(message.flags & Components.interfaces.nsMsgMessageFlags.Read));
Code: Select all
var win = Services.wm.getMostRecentWindow("mail:3pane");
var uid = "__unique_identifier_FiltaQuilla";
var subject = message.mime2DecodedSubject;
var author = message.mime2DecodedAuthor;
Application.console.log("FiltaQuilla: " + [subject, author].join(", "));
Application.console.log("FiltaQuilla: " + JSON.stringify(win[uid]));
if (message.flags & Components.interfaces.nsMsgMessageFlags.Read) {
Application.console.log("FiltaQuilla: message is read");
} else {
Application.console.log("FiltaQuilla: message is unread");
}
(false);