niXforums Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   PreferencesPreferences   Log in to check your private messagesLog in to check your private messages   Log inLog in 
·  nixdoc.net ·  man pages ·  Linux HOWTOs ·  FreeBSD Tips ·  Forums
navigation Forum index » Programming » python
IMAP4 search with special characters
Post new topic   Reply to topic Page 1 of 1 [1 Post] View previous topic :: View next topic
Author Message
Luis Corrales
*nix forums beginner


Joined: 21 Jul 2006
Posts: 1

PostPosted: Fri Jul 21, 2006 7:51 am    Post subject: IMAP4 search with special characters Reply with quote

Hi all,

I have a problem when searching for text with special characters in
e-mails in an IMAP server. I'm using imaplib in python 2.4.3 and I can't
get this code working:

# first connect and login
conn = IMAP4(my_server)
conn.login(my_user, my_pass)

# now select INBOX
conn.select('INBOX')

# and search for messages (the first parameter of "search" is the
encoding, which defaults to None)
conn.search(None, '(ALL)') # output: ('OK', ['1 2 3'])

# That works perfectly and I get the 3 messages that I have in my Inbox:
# Now I want to search for messages with special characters. This works
(still no special characters in my search):

conn.search(None, '(BODY gasse)')

# and even this:

conn.search('ISO-8859-1', '(BODY gasse)')

# but not this (there comes the 'ö'):

conn.search('ISO-8859-1', '(BODY Lemböckgasse)') # error: SEARCH
command error: BAD ['Bogus criteria list in SEARCH']

# After having read the IMAP4 documentation I thought this could work:

conn.search('ISO-8859-1', '(CHARSET ISO-8859-1 BODY Lemböckgasse)')

# I tried everything that came up to my mind, getting always the same
error. For instance:

conn.search(None, '(CHARSET ISO-8859-1 BODY Lemböckgasse)')
conn.search(None, '(BODY Lemb\xf6ckgasse)')
conn.search(None, '(BODY Lemböckgasse)'.encode('ISO-8859-1')) # here I
get the error "can't decode byte 0xf6 in position 10"
conn.search('ISO-8859-1', '(BODY Lemböckgasse)'.encode('ISO-8859-1'))

And so on. Does anybody have the remotest idea what I'm doing wrong and
how I could find my e-mail?

Thanks in advance,

Luis Corrales
Back to top
Google

Back to top
Display posts from previous:   
Post new topic   Reply to topic Page 1 of 1 [1 Post] View previous topic :: View next topic
The time now is Thu Dec 04, 2008 8:25 am | All times are GMT
navigation Forum index » Programming » python
Jump to:  

Similar Topics
Topic Author Forum Replies Last Post
No new posts Best method to search kristy420 Oracle 0 Tue Nov 18, 2008 6:34 pm
No new posts Bug#379104: ITP: complearn-mpi -- parallel quartet tree s... Rudi Cilibrasi devel 0 Fri Jul 21, 2006 11:30 am
No new posts Array and Search function cdf PHP 2 Thu Jul 20, 2006 12:01 pm
No new posts FULL TEXT search and Thai Peter Lauri MySQL 2 Wed Jul 19, 2006 5:11 am
No new posts Search for text string in files Chuckk Hubbard Debian 3 Wed Jul 19, 2006 1:20 am

Credit Cards | Mortgage Loans | Free Ringtones | Credit Cards UK | Home Loan
Copyright © 2004-2005 DeniX Solutions SRL
 
Other DeniX Solutions sites: Unix/Linux blog |  electronics forum |  medicine forum |  science forum | 
Privacy Policy


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 0.0976s ][ Queries: 16 (0.0341s) ][ GZIP on - Debug on ]