email module - getting unicode string from header?

A

Andrew McNamara

Given an email.Message.Message() object, what is the canonical way to
obtain a list of unicoded address headers? This is the effect I'm trying
to achieve, but it seems somewhat cumbersome:
>>> from email.Header import make_header, decode_header
>>> from email.Utils import formataddr, getaddresses
>>> [unicode(make_header(decode_header(formataddr(t))))
for t in getaddresses(m.get_all('to')+m.get_all('cc'))]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,209
Messages
2,571,088
Members
47,686
Latest member
scamivo

Latest Threads

Top