Hi,
pyMSNt doesn't encoding fields: From and Subject in email
notification.
It's only removing information about 'us-ascii'. And if this fields
are decoded in other encoding, it will even show information about
this...
Definition of this is in msn.py:1009
def _gotEmailNotification(self, message):
values = self._getEmailFields(message)
try:
mailfrom = values["From"]
fromaddr = values["From-Addr"]
subject = values["Subject"]
junkbeginning = "=?\"us-ascii\"?Q?"
junkend = "?="
subject = subject.replace(junkbeginning, "").replace
(junkend, "").replace("_", " ")
except KeyError:
# If any of the fields weren't found then it's not a big
problem. We just ignore the message
return
self.gotRealtimeEmailNotification(mailfrom, fromaddr, subject)
I have found, that it can use decode_header from email.Header. to do
this.
I'm beginner in python, so I don't know if this is OK, but I tried to
do fix:
def _gotEmailNotification(self, message):
values = self._getEmailFields(message)
try:
mailfrom = values["From"]
fromaddr = values["From-Addr"]
subject = values["Subject"]
except KeyError:
# If any of the fields weren't found then it's not a big
problem. We just ignore the message
return
self.gotRealtimeEmailNotification(encodeEmailField(mailfrom),
fromaddr, encodeEmailField(subject))
from email.Header import decode_header
def encodeEmailField(field)
for header, encoding in decode_header(field):
if encoding is None:
print header.decode()
else:
print header.decode(encoding)
return field
Best regards,
Lukasz
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"py-transports" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/py-transports?hl=en
-~----------~----~----~----~------~----~------~--~---