473,320 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

IMAP4 search with special characters


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
Jul 21 '06 #1
0 1501

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sean Dodsworth | last post by:
Can anyone tell me how to get a message's number from the message-id using IMAP4.search? I've tried this: resp, items = server.search(None, 'HEADER', '"Message-id"', msgID) but it gives me a...
23
by: SeaPlusPlus | last post by:
I want to convert large files of prose to xhtml and so I need a way to remove unwanted line wraps. So, I'm looking for a freebee editor that has the capability of searching for a single "carriage...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
0
by: Laszlo Nagy | last post by:
Hi, I'm using imaplib to access an IMAP4 server. I'm reading the IMAP4 specification, and I found something odd. The search command can be used in conjuction with date values. For example, I...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.