Please consider registering

sp_LogInOut Log In sp_Registration Register

Register | Lost password?
Advanced Search

— Forum Scope —

— Match —

— Forum Options —

Minimum search word length is 3 characters - maximum search word length is 84 characters

sp_Feed Topic RSS sp_TopicIcon
Need to add recipient, NOT sender, to addr book in filter action
August 31, 2016
2:49 am
New Member
Forum Posts: 1
Member Since:
August 31, 2016
sp_UserOfflineSmall Offline

I need a filter action to run when an incoming email is added to a folder, which adds that email's recipient to a specific address book. I even tried to come up with some javascript that would do this, but the MDN javascript documentation is 100% impenetable, just as unhelpful as could possibly be (and I programmed websites in javascript for 10 years, it's not like I'm not capable of understanding it). Is there some way to do this?

September 1, 2016
3:37 pm
Forum Posts: 423
Member Since:
July 12, 2008
sp_UserOfflineSmall Offline

The sample JS for a filter action is shown here:

for (let index = 0; index < msgHdrs.length; index++)
let hdr = msgHdrs.queryElementAt(index, Ci.nsIMsgDBHdr);
hdr.subject = "[Hello, world] " + hdr.subject;

that is from

Within the source to FiltaQuilla itself, the equivalent code for the add sender filter action is:

let count = aMsgHdrs.length;
for (let i = 0; i < count; i++)
let hdr = aMsgHdrs.queryElementAt(i, Ci.nsIMsgDBHdr);
let addresses = {}, names = {};
headerParser.parseHeadersWithArray(hdr.mime2DecodedAuthor, addresses, names, {});
names = names.value;
addresses = addresses.value;
if (addresses.length)
// don't add the address if it already exists. Mailing lists seem to
// detect this themselves.
if (!dir.isMailList && dir.cardForEmailAddress(addresses[0])) {

let card = Cc[";1"]
card.primaryEmail = addresses[0];
card.displayName = names[0];

Do you see that hdr.mime2DecodedAuthor? What you want instead is hdr.mime2DecodedRecipients As a qualified JS programmer, you should be able to make that minor change (along with some renaming of variable like msgHdrs/aMsgHdrs.

The gotcha here is that the recipients is multi-valued, while the author is single valued. You may have to separate the recipients into individual items (probably comma separated) and apply to each individually.

I hope this helps. I really can't just write it for you. You might find it easier to just modify the source to FiltaQuilla, changing author to recipient in that filter action, if this is just for your own use.

Forum Timezone: UTC -8

Most Users Ever Online: 41

Currently Online:
5 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

BigMike: 14

David.P: 10

Jeff Wexler: 9

taa: 8

JPRuehmann: 8

bobkatz: 8

Member Stats:

Guest Posters: 217

Members: 4714

Moderators: 2

Admins: 1

Forum Stats:

Groups: 1

Forums: 7

Topics: 383

Posts: 1228

Newest Members:

JaimeToisM, Maririz, FitoSprayiBeery, MichaelHoarm, JordonReasonovertrog, Rysrejsnade

Administrators: rkent: 423