title: Sending email from raised exception in Python
body: <p>I would like to send an email from all of my raised exceptions that appear in the console in a Python script.  An example of this would be if a json-web service that I am consuming is down and logs an error message to my console; then I would like to send that in addition to any other errors that are logged in the console.</p>
  
  <p>At the lowest level; here is an example of what I would encounter.  I would like to email all associated errors with the script if it fails, or returns <code>exit code 1</code></p>
  
  <pre><code>import json
  import jsonpickle
  import requests
  import time
  
  f2 = open('C:\Users\Administrator\Desktop\DetailView.json', 'r')
  data2 = jsonpickle.encode(jsonpickle.decode(f2.read()) )
  url2 = "HTTPERROR or ValueError prone URL that raises an exception"
  headers2 = {'Content-type': 'text/plain', 'Accept': '/'}
  r2 = requests.post(url2, data=data2, headers=headers2)
  decoded2 = json.loads(r2.text)
  Start = datetime.datetime.now()
  </code></pre>
  
  <p><code>
  ValueError: No JSON object could be decoded</code></p>