[Python-es] Adjuntos correo - Crear MIMEBase ya con un fichero ya en base64

Raimon Esteve raimonesteve en gmail.com
Mar Sep 4 18:27:55 CEST 2012


Hola,

pregunta:

recibo un fichero ya en base64 y lo debo adjuntar en un correo electronico.
Leyendo, el set_payload lo codifica con base64. Por tanto, tengo un base64
de base64, y el fichero adjunto, pues esta dañado.

como lo haceis?

Ahora dispongo de este código, donde

 * data: recibo el fichero en base 64
 * filename: recibo el nombre del fichero

                    data, filename = report[1:3]
                    content_type, _ = mimetypes.guess_type(filename)
                    maintype, subtype = (
                        content_type or 'application/octet-stream'
                        ).split('/', 1)

                    attachment = MIMEBase(maintype, subtype)
                    attachment.set_payload(data)


http://docs.python.org/library/email.mime.html
http://docs.python.org/library/email.message.html?highlight=set_payload#email.message.Message.set_payload

-- 
Si us plau, NO adjunti arxius a les seves respostes. Li preguem que integri
el text al cos del missatge. Pot respondre usant NetEtiquete que li ajudarà
a seguir la conversa. http://es.wikipedia.org/wiki/Netiquette

Por favor, NO adjunte archivos a sus respuestas. Le rogamos que integre el
texto en el cuerpo del mensaje. Puede responder usando NetEtiquete que le
ayudará a seguir la conversación.http://es.wikipedia.org/wiki/Netiquette

Please, DO NOT send attachment files with your answers, just copy and paste
only the text you need to send into the body of your mails. Repply using
NetEtiquete. http://en.wikipedia.org/wiki/Netiquette
------------ próxima parte ------------
Se ha borrado un adjunto en formato HTML...
URL: <http://mail.python.org/pipermail/python-es/attachments/20120904/904f674b/attachment.html>


Más información sobre la lista de distribución Python-es