It's OK. Thank Alan Etkin.

I need attachments file name before download (ex: big file), how do you get 
it?
I try added new field "files" and modified function "select" IMAP, it's 
work for me: 

            for part in message.walk():
                maintype = part.get_content_maintype()
                if ("%s.attachments" % tablename in colnames) or \
                   ("%s.files" % tablename in colnames) or \
                   ("%s.content" % tablename in colnames):
                    payload = part.get_payload(decode=True)
                    if payload:
                        filename = part.get_filename()
                        values = {"mime": part.get_content_type()}
                        #if ((filename or not "text" in maintype) and
                        if (filename):
                            if ("%s.attachments" % tablename in colnames):
                                values.update({"payload": payload,
                                    "filename": filename,
                                    "encoding": part.get_content_charset(),
                                    "disposition": 
part["Content-Disposition"]})
                                attachments.append(values)
                            if ("%s.files" % tablename in colnames):
    files.append({'filename':filename,'size':len(payload)})
                        elif (("text" in maintype) and
                              ("%s.content" % tablename in colnames)):
                            values.update({"text": self.encode_text(payload,
                                               self.get_charset(part))})
                            content.append(values)

                if "%s.size" % tablename in colnames:
                    if part is not None:
                        size += len(str(part))
            item_dict["%s.content" % tablename] = content
            item_dict["%s.files" % tablename] = files
            item_dict["%s.attachments" % tablename] = attachments
            item_dict["%s.size" % tablename] = size
            imapqry_list.append(item_dict)





Vào 02:45:32 UTC+7 Thứ hai, ngày 07 tháng mười năm 2013, Alan Etkin đã viết:
>
> I am testing it too and for some mail got this traceback:
>>> ERROR:web2py.dal:Could not parse date text: 10 Dec 2012 02:23:50 +0100. 
>>> need more than 1 value to unpackou 
>>>
>>
> There's a pending pull request that should fix the issue
>
> http://github.com/web2py/web2py/pull/241
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to