Python mail truncate problem

Tim Roberts timr at probo.com
Wed May 20 02:34:37 EDT 2009


David <Wwy58 at yahoo.com> wrote:
>
>I am writing Python script to process e-mails in a user's mail
>account. What I want to do is to update that e-mail's Status to 'R'
>after processing it, however, the following script truncates old e-
>mails even though it updates that e-mail's Status correctly. Anybody
>knows how to fix this?

Truncates in what way?  When I tried this, it seemed to work fine.

Note, however, that it is somewhat dangerous to modify an iterator while
you are using it.  (That is, you are setting mbox[key] while doing
mbox.iteritems.)  I might suggest you grab the keys as a list and iterate
through them:

   for key in mbox.keys():
       msg = mbox[key]
       ...
-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the Python-list mailing list