0

BlackBerry 10 devices only send out HTML email.

While this is "great" for the movement to discard legacy content (separate argument), it's annoying when you need plain text. It's just not available.

How do you get plain text from an email send by a BB10 device?

0
1

Using python and xpath, extract text from the HTML:

#!/usr/bin/python3
import urllib.request
import quopri
import lxml.html

# actual test fragments are here
raw_url = 'https://gist.github.com/Supermathie/7866658/raw/80e4abd4226b916a54b224677af7fda881d0937f/sample+1'
raw_url_no_sig = 'https://gist.github.com/Supermathie/7866658/raw/df354d6b8f3176c3d8bdb89b2961bb0ccc78520c/sample+2'

def get_divs(url):
    email_body_raw = urllib.request.urlopen(url).read()
    email_body = quopri.decodestring(email_body_raw)
    email_xml = lxml.html.document_fromstring(email_body)
    email_divs = email_xml.xpath('//div[@id="_signaturePlaceholder"]/preceding-sibling::div')
    return email_divs

print('\n'.join([str(node.text_content() or "") for node in get_divs(raw_url)]))
print('\n'.join([str(node.text_content() or "") for node in get_divs(raw_url_no_sig)]))

For the two test cases, prints:

Let's remember that the information in the article was filtered through no less than two people who don't fully speak tech. I think I can translate it back:

«The FBI crafted a custom piece of malware targeting Mo, designed to snoop his activities . A link was emailed to Mo in a spear phishing attack in an attempt to get hin to download and install the malware from the FBI's monitored servers. 

The attempt failed; the software was downloaded but never executed in a manner enabling the software to send back information to the FBI.»

Nothing too special. I wonder if Mo had the balls to submit the software to Sophos etc. for malware analysis. :)

M.

and

Test email

No signature

1
  • Actually, yes you can. I've written and deployed a Python app to a BB10 device. In fact, a significant portion of the UI on BB10 devices is written in Python. Regardless, this question is about extracting text from email sent by the device. I just happened to use Python to demonstrate my solution. – MikeyB Dec 9 '13 at 9:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.