I would like to have an action triggered whenever a message (or messages) are added to a TB folder, whether they're copied there manually or end up there through the application of a filter.
Specifically, I'd like the incoming message to be copied to a location in 'Local Folders' for safekeeping.
I haven't found anything like this yet, and it's unclear if there's even an event API that covers this sort of thing, to which I could subscribe a hook.
Any pointers would be extremely welcome!
Thanks..
Event triggered on add of message to TB folder?
-
- Posts: 5
- Joined: January 1st, 2017, 11:17 am
- DanRaisch
- Moderator
- Posts: 127240
- Joined: September 23rd, 2004, 8:57 pm
- Location: Somewhere on the right coast
Re: Event triggered on add of message to TB folder?
Perhaps you haven't considered using Message Filters for that purpose.
-
- Posts: 5
- Joined: January 1st, 2017, 11:17 am
Re: Event triggered on add of message to TB folder?
I have, but as I described, they don't fit the bill. Dragging a message to a folder by hand isn't going to trigger a filter action. Filters work on where the message originates; I need something that acts when the message arrives in a destination folder.
- DanRaisch
- Moderator
- Posts: 127240
- Joined: September 23rd, 2004, 8:57 pm
- Location: Somewhere on the right coast
Re: Event triggered on add of message to TB folder?
How is the account set up in Thunderbird, as POP or IMAP?
-
- Posts: 5
- Joined: January 1st, 2017, 11:17 am
Re: Event triggered on add of message to TB folder?
The account with the folders I want to watch is Google IMAP. The account to which I want messages copied is 'Local Folders'.
- DanRaisch
- Moderator
- Posts: 127240
- Joined: September 23rd, 2004, 8:57 pm
- Location: Somewhere on the right coast
Re: Event triggered on add of message to TB folder?
OK, then the filters would work automatically only on messages newly arrived to the account's Inbox. You could set up a Saved Search that seeks messages in that Gmail account, including sub-folders, but the action triggered by such a search would not copy the new messages to separate folders but only to one destination folder under Local Folders, probably not an acceptable solution.
Is it critical that you access that account as an IMAP account?
Is it critical that you access that account as an IMAP account?
-
- Posts: 5
- Joined: January 1st, 2017, 11:17 am
Re: Event triggered on add of message to TB folder?
Yes, there is no choice about the IMAP aspect. That's why I'm hoping there's some sort of event API that includes a 'message arrived in folder' event that I can hook.
-
- Posts: 6432
- Joined: February 3rd, 2009, 6:29 pm
Re: Event triggered on add of message to TB folder?
You can use a folder listener like the Mailbox Alert extension.
https://dxr.mozilla.org/comm-release/so ... stener.idl
https://dxr.mozilla.org/comm-release/so ... ession.idl
Code: Select all
var folderListener = {
OnItemAdded: function (parentItem, item) {
MailServices.mailSession.RemoveFolderListener(folderListener);
var folder = parentItem.QueryInterface(Components.interfaces.nsIMsgFolder);
var msgHdr = item.QueryInterface(Components.interfaces.nsIMsgDBHdr);
alert([folder.abbreviatedName, msgHdr.mime2DecodedAuthor,
msgHdr.mime2DecodedSubject, msgHdr.mime2DecodedRecipients].join("\n"));
},
};
var notifyFlags = Components.interfaces.nsIFolderListener.added;
MailServices.mailSession.AddFolderListener(folderListener, notifyFlags);
https://dxr.mozilla.org/comm-release/so ... ession.idl
-
- Posts: 5
- Joined: January 1st, 2017, 11:17 am
Re: Event triggered on add of message to TB folder?
That looks awesomely like what I want. Thanks! I'll check it out!