Hi Alan,
By example at:
http://www.web2pyslices.com/slice/show/1706/how-to-compose-a-multi-attachment-draftnormal-email-with-imapsmtp
I have modified:
if form.vars.draft:
request.vars[k].file.seek(0)
payload = request.vars[k].file.read()
attachments.append(dict(payload=payload, filename=filename,
mime="application/vnd.ms-excel"))
to attach a ms-excel file, but the attachment (was successfully inserted)
in draft is not correct data. Can you help me?
Vào 10:37:56 UTC+7 Thứ hai, ngày 07 tháng mười năm 2013, IVINH đã viết:
>
> 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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.