Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Deleting email message using imaplib?

Reply
Thread Tools

Deleting email message using imaplib?

 
 
Bill Sneddon
Guest
Posts: n/a
 
      08-25-2003
Anyone have an example they are willing to share that shows
how to use the store command in imaplib?

store( message_set, command, flag_list)
Alters flag dispositions for messages in mailbox.

I have been unable to find one or get the syntax correct through
trial and error.

I can send the command to the server in the following manor.
The only problem is I can not get the response back from the server.
I tried the recent() and the responce(code) objects with no success.
Not sure what the code should be.

I would be open to a different approach to delete a message if one exist.


This is example of deleting from PythonWin.


>>> m.send('A003 STORE 2:4 +FLAGS (\Deleted)')
>>> m.recent()

('OK', ['0'])
>>> m.expunge()

Traceback (most recent call last):
File "<interactive input>", line 1, in ?
File "C:\Python23\lib\imaplib.py", line 402, in expunge
typ, dat = self._simple_command(name)
File "C:\Python23\lib\imaplib.py", line 1000, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "C:\Python23\lib\imaplib.py", line 832, in _command_complete
raise self.abort('command: %s => %s' % (name, val))
abort: command: EXPUNGE => unexpected response: 'A0032 OK STORE completed'
>>> m.expunge()

('OK', ['2', '2', '2'])


Thanks for your help. Sorry if this is a FAQ but I looked and could not
find the answer.

Bill Sneddon

 
Reply With Quote
 
 
 
 
Mark Roach
Guest
Posts: n/a
 
      08-25-2003
On Mon, 25 Aug 2003 16:14:45 -0400, Bill Sneddon wrote:

> Anyone have an example they are willing to share that shows
> how to use the store command in imaplib?

[...]
> >>> m.send('A003 STORE 2:4 +FLAGS (\Deleted)')


here's what I use, works just fine.

imconn = imaplib.IMAP4(server)
imconn.login(username, password)
imconn.select(folder)
imconn.store(msgid, "+FLAGS", '(\\Deleted)')
imconn.expunge()


-Mark
 
Reply With Quote
 
 
 
 
Bill Sneddon
Guest
Posts: n/a
 
      08-25-2003
Mark Roach wrote:

Thanks,
Works for me too. I did not escape the \.
rookie mistake (:


Bill

> On Mon, 25 Aug 2003 16:14:45 -0400, Bill Sneddon wrote:
>
>
>>Anyone have an example they are willing to share that shows
>>how to use the store command in imaplib?

>
> [...]
>
>> >>> m.send('A003 STORE 2:4 +FLAGS (\Deleted)')

>
>
> here's what I use, works just fine.
>
> imconn = imaplib.IMAP4(server)
> imconn.login(username, password)
> imconn.select(folder)
> imconn.store(msgid, "+FLAGS", '(\\Deleted)')
> imconn.expunge()
>
>
> -Mark


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Deleting data from the file without deleting the file first crea C++ 2 12-28-2012 11:50 PM
Strange effects using the email.message.Message class Rogério Brito Python 1 09-09-2009 04:19 AM
Why don't links open from an email message or a news group message? Jeff Strickland Computer Information 9 04-10-2008 08:02 PM
Deleting a File from Hardrive and Deleting a SubKey in Registry Harry Barker C++ 2 04-19-2006 09:34 AM
[python] Figured out how to go from email.Message.Message to string David Stockwell Python 1 06-17-2004 08:52 PM



Advertisments