Next: Utility procedures, Previous: Contact procedures and objects, Up: Contacts [Contents]
Sometimes you may want to inspect all the different contacts in the mu database. This is useful, for instance, when exporting contacts to some external format that can then be important in an e-mail program.
To enable this, there is the procedure mu:for-each-contact
, defined as
(mu:for-each-contact procedure [search-expression])
.
This will aggregate the unique contacts from all messages matching <search-expression> (when it is left empty, it will match all messages in the database), and execute procedure for each of them.
The procedure receives an object of the type <mu:contact-with-stats>, which is a subclass of the <mu:contact> class discussed in See Contact procedures and objects. <mu:contact-with-stats> objects expose the following additional methods:
(mu:frequency <contact>)
: returns the number of times this contact occured in
one of the address fields
(mu:last-seen <contact>)
: returns the most recent time the contact was
seen in one of the address fields, as a time_t value
The method assumes an e-mail address is unique for a certain contact; if a certain e-mail address occurs with different names, it uses the most recent non-empty name.