maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Maemo 5 / Fremantle (https://talk.maemo.org/forumdisplay.php?f=40)
-   -   searching for emails (https://talk.maemo.org/showthread.php?t=87445)

impeham 2012-10-18 13:12

searching for emails
 
Is there a way to search for an email (search from/to/subject/body through all emails) using a customized search string somehow?

reinob 2012-10-18 13:41

Re: searching for emails
 
If you mean searching e-mails that Modest keeps in its cache (or e-mail that you have actively stored in a local folder), *and* you don't mind using the power of regular expressions, you can do the following:

$ find ~/.modest/cache/mail -name \*.~ | xargs grep "findme"

This will go through all locally-cached e-mails and for each one it will look for the "findme" string (learn to use grep and you'll never look back :)

Obviously this is not fully practical, as it will display the full path of the e-mails matching the input string. With suitable scripting you could print, for each e-mail found, the from/to/date/subject header and perhaps a couple of context lines.

Alternatively, if you make this into some kind of interactive program, you could present the list to the user and allow to click on a result and open modest showing that e-mail (probably there's some dbus-ish way of doing this).

If you use alpine (like I do), you can use "alpine -F /path/to/e-mail" to view the e-mail (with e.g. the option to forward).

But then you need to, before piping it to pine, add a fake "From .." line so that it conforms to the mbox format.

Hey, this looks like an idea for a nice script.

impeham 2012-10-18 13:59

Re: searching for emails
 
i hoped that there will be an application that does it already or an option i missed, but i guess eventually that there's nothing like some bash scripting :)

reinob 2012-10-18 14:09

Re: searching for emails
 
He, that was fun:

Code:

BASEPATH=$HOME/.modest/cache/mail
MBOXVIEW=alpine -F

SEARCHSPEC="-s -i $1"

for m in $(find $BASEPATH -name \*.~ | xargs grep -l $SEARCHSPEC | uniq)
do
        $MBOXVIEW $m
done

(typed by hand, so may not work straight out of the box).

It searches for the expression you give it and for each e-mail found it displays it using alpine. When you hit "Q" it jumps to the next e-mail that was found, until you've seen them all.

Need to work on on-the-fly patching the modest e-mails to that they display as a proper e-mail in alpine (the "From " trick didn't work).

unexpected 2012-10-18 14:48

Re: searching for emails
 
is there any other email app for n900 except the stock one?

impeham 2012-10-19 10:18

Re: searching for emails
 
I'm having some difficulties installing alpine - posted here:

http://talk.maemo.org/showpost.php?p...5&postcount=12

reinob 2012-10-22 08:00

Re: searching for emails
 
Quote:

Originally Posted by unexpected (Post 1282144)
is there any other email app for n900 except the stock one?

Claws-mail (GUI, but not optimized for a small touch screen), alpine (non-graphical UI, can use the stylus for clicking around), mutt (some people like it, I prefer alpine).

impeham 2012-11-11 20:07

Re: searching for emails
 
Quote:

Originally Posted by reinob (Post 1282121)
He, that was fun:

Code:

BASEPATH=$HOME/.modest/cache/mail
MBOXVIEW=alpine -F

SEARCHSPEC="-s -i $1"

for m in $(find $BASEPATH -name \*.~ | xargs grep -l $SEARCHSPEC | uniq)
do
        $MBOXVIEW $m
done

(typed by hand, so may not work straight out of the box).

It searches for the expression you give it and for each e-mail found it displays it using alpine. When you hit "Q" it jumps to the next e-mail that was found, until you've seen them all.

Need to work on on-the-fly patching the modest e-mails to that they display as a proper e-mail in alpine (the "From " trick didn't work).

this script works great - any advices for user experience improvements :) ?
for example - there is much stuff in each email that is not needed (headers etc.) - can it be cleaned?

Is it possible to view as HTML?

impeham 2012-11-11 21:37

Re: searching for emails
 
I had an idea of how to be able to view the emails found in the search process of the script using the built in email application -here is what I did:

Using the email application I've created a new folder - "Test", then I moved one of my emails from the inbox to this folder. Now I could see that the following folder was created in the FS: "/home/user/.modest/local_folders/Test".

My moved email file was found at: "/home/user/.modest/local_folders/Test/cur".

Next step - I copied the emails I found with your search script into "/home/user/.modest/local_folders/Test/cur" and tried to see them with the built in email application - I could still only see the email I had moved before.

Checking further, I've noticed that when a message Is moved to this folder, another file is being updated:

/home/user/.modest/local_folders/Test.ev-summary.mmap

It seems that this file holds the list of email files (with their subject etc.) in some binary format.

I replaced the file of the email I moved at first with another email file and tried to open it with the email application - It was successful - even though the "Subject" of the email was the old one (the details were stored in "/home/user/.modest/local_folders/Test.ev-summary.mmap"), its content was of the newly copied email file.

If there was a way to update the "Test.ev-summary.mmap" and add to it new files being added to "/home/user/.modest/local_folders/Test/cur" (the ones found in the search process), we could view these emails at the end of the search very nicely with the built in application including HTML content and pictures.

Thoughts about progressing with this are very welcome.


All times are GMT. The time now is 01:58.

vBulletin® Version 3.8.8