1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# Import package to access Outlook
import win32com.client
import re
import xml.dom.minidom as minidom
resultslis=[]

def getsanityresults(xmlfile):
  dom = minidom.parse(xmlfile)
  data=dom.getElementsByTagName('Sanity_Results')
  textnode = data[0].childNodes[0]
  testresults=textnode.data
  for line in testresults.splitlines():
    line = line.strip('\r,\n')
    line = re.sub(r'(http://[^\s]+|//[^\s]+|\\\\[^\s]+)', r'<a href="\1">\1</a>', line)
    print line     
    resultslis.append(line)
  return resultslis

def main ():
  file = open('results.xml','r')
  sanityresults=getsanityresults(file)
  print sanityresults
  msg_body=("<HTML><head></head>"
        "<body> <font face = \"Calibri\" <br>"
          "<font face = \"Calibri\"%s<br><br>"

        "</body></html>"
        ) % (sanityresults)

  olMailItem = 0x0
  obj = win32com.client.Dispatch("Outlook.Application")
  newMail = obj.CreateItem(olMailItem)
  newMail.HTMLBody = msg_body
  newMail.display()

if __name__ == '__main__':
  main()