Problem with ImapLib and subject in French

Arnaud Delobelle arnodel at gmail.com
Mon Jun 18 16:55:53 CEST 2012


On 18 June 2012 12:31, Valentin Mercier <merciervspam at gmail.com> wrote:
> Hi,
>
> I'm trying to search some mails with SUBJECT criteria, but the problem is
> the encoding, I'm trying to search french terms (impalib and python V2.7)
>
> I've tried few things, but I think the encoding is the problem, in my mail
> header I have something like this:
>
>  =?iso-8859-1?Q?Job:_"Full_Backup_Les_Gr=E8ves_du_Lac")_?=
>
> I need to search unseen mail with the FROM and the SUBJECT criteria. I take
> those two in parameters in my python script and the second contain special
> caracters like é or è, so I encode the string like this:
>
>              temp = header_encode(unicode('Les grèves','utf-8'),
> charset='iso-8859-1')
>
> And the string is exactly the same as the header:
>
> =?iso-8859-1?q?Full_Backup_Les_Gr=E8ves?=
>
> But the search function doesn't find my email, and I don't know why, even if
> I try with the entire string of the subject.

Can you post the code that doesn't work?  It's hard to debug "search
function doesn't find my email".  It would be easier to debug actual
code (note: I'm not a user of imaplib so I'm not promising anything :)

-- 
Arnaud


More information about the Python-list mailing list