473,387 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

mail attachment with non-ascii name

I am using the "email" module to decode incoming messages.
(with msg = email.message_from_file( msg_file ))
Sometimes an attachment has its name (as returned by
msg.walk().part.get_filename()) not in ASCII (e.g.
'=?iso-8859-1?q?somefile=2ezip?=') How can I turn that into
simply 'somefile.zip' ? I have looked into email.Utils and
codecs, but cannot find what should work.

TIA,

Bernard.
Dec 11 '05 #1
2 1563
Bernard Delmée:
I am using the "email" module to decode incoming messages.
(with msg = email.message_from_file( msg_file ))
Sometimes an attachment has its name (as returned by
msg.walk().part.get_filename()) not in ASCII (e.g.
'=?iso-8859-1?q?somefile=2ezip?=') How can I turn that into
simply 'somefile.zip' ? I have looked into email.Utils and
codecs, but cannot find what should work.

import email.Header
x = '=?iso-8859-1?q?somefile=2ezip?='
email.Header.decode_header(x)

[('somefile.zip', 'iso-8859-1')]

Neil
Dec 11 '05 #2
Thank you Neil,

that is what I needed.

B.

Neil Hodgson wrote:
>>> import email.Header
>>> x = '=?iso-8859-1?q?somefile=2ezip?='
>>> email.Header.decode_header(x)

[('somefile.zip', 'iso-8859-1')]

Neil

Dec 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: joealey2003 | last post by:
Hi all... A simple mail example like... <? mail("acco...@yahoo.com","Subject of Message","Message"); ?> does not work to yahoo or spymac.com, but the same works to gmail and other servers.
0
by: jrb3 | last post by:
Warning: This message has had one or more attachments removed Warning: (attachment.scr). Warning: Please read the "VirusWarning.txt" attachment(s) for more information. The original message was...
0
by: imre.adam | last post by:
The original message was received at Wed, 2 Mar 2005 20:06:59 +0100 from 87.26.243.56 ----- The following addresses had permanent fatal errors ----- <python-list@python.org> ----- Transcript...
2
by: Cutlass | last post by:
Hello I'm using the following code to send mail from VB.NET 2003 Imports System.Web.Mail .. .. Dim oMail as System.Web.Mail.SmtpMail Dim Attachment as System.Web.Mail.MailAttachment Dim...
1
by: praba kar | last post by:
Dear All, I am new to python world. I have pasted my code which I used it to build rfc822 format mails for webbased mailing system task(which is like to yahoo.com web interface). Now I am...
7
by: brigitte | last post by:
Hi, I'm having trouble with a specific e-mail text format attachment ... The requirement is for the attachment to be .txt type and in this format: Label=FieldValue Label=FieldValue...
1
by: Lelle | last post by:
Sorry for crossposting - sent to wrong group first hello ! does anyone have more information regarding this issue? http://www.systemwebmail.com/faq/2.3.aspx a.. Attachment Size Limit? ...
1
by: theWizard1 | last post by:
The following sends my email, but the attachment is empty. The attachment should contain the data that is in the string that was created from the xmlReader. I have a stored procedure written...
0
by: =?Utf-8?B?TWlrZQ==?= | last post by:
Hi. I'm using System.Web.Mail to compose and send a message. I'm receiving an "Access is denied" error message when non-Domain Administrators attach files to the MailMessage. My allows users...
1
by: rengaraj | last post by:
hi dears! in my webapp i have some users, thats are in 3 Roles. i want to do communication between them via mail system. this means that Role 1 attach one file and this file must send via mail...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.