title: Python TypeError: sequence item 0: expected string, list found in message body of email code
body: <p>I am trying to send some data in my email code in the body part of the email message. I am calling 2 functions which returns a list. I would like to include these into the email body part of the message. I am getting the error TypeError: sequence item 0: expected string</p>
  
  <pre><code>    Traceback (most recent call last):
    File "E:/test_runners 2 edit project in progress add more tests/selenium_regression_test_5_1_1/Email/email_selenium_report.py", line 32, in &lt;module&gt;
      report.send_report_summary_from_htmltestrunner_selenium_report2()
    File "E:\test_runners 2 edit project in progress add more tests\selenium_regression_test_5_1_1\Email\report.py", line 318, in send_report_summary_from_htmltestrunner_selenium_report2
      '\n'.join(extract_testcases_from_report_htmltestrunner()) +
  TypeError: sequence item 0: expected string, list found
  </code></pre>
  
  <p>My email code is:</p>
  
  <pre><code>def send_report_summary_from_htmltestrunner_selenium_report2():
      print extract_only_header_from_summary_from_report_htmltestrunner()
      print extract_header_count__from_summary_from_report_htmltestrunner()
      all_testcases = list(extract_testcases_from_report_htmltestrunner())
      # print all_data
      pprint.pprint(all_testcases)
  
      msg = MIMEText("\n ClearCore 5_1_1 Automated GUI Test_IE11_Selenium_VM   \n " +
                     '\n'.join(extract_only_header_from_summary_from_report_htmltestrunner()) +
                     '\n'.join(extract_header_count__from_summary_from_report_htmltestrunner()) +
                     '\n'.join(extract_testcases_from_report_htmltestrunner()) +
                     "\n Report location = : \\storage-1\Testing\Selenium_Test_Report_Results\ClearCore_5_1_1\Selenium VM\IE11 \n")
  
  
      msg['Subject'] = "ClearCore 5_1_1 Automated GUI Test"
      msg['to'] = "riaz.ladhani@company.onmicrosoft.com"
      msg['From'] = "system@company.com"
  
      s = smtplib.SMTP()
      s.connect(host=SMTP_SERVER)
      s.sendmail(msg['From'], msg['To'], msg.as_string())
      s.close()
  </code></pre>
  
  <p>My 3 functions which return the list are:</p>
  
  <pre><code>def extract_only_header_from_summary_from_report_htmltestrunner():
      filename = (r"E:\test_runners 2 edit project\selenium_regression_test_5_1_1\TestReport\ClearCore501_Automated_GUI_TestReport.html")
      html_report_part = open(filename,'r')
      soup = BeautifulSoup(html_report_part, "html.parser")
      table = soup.select_one("#result_table")
  
      #Create list here...
      results = []
  
      headers = [td.text for td in table.select_one("#header_row").find_all("td")[1:-1]]
  #    print(" ".join(headers))
  
      #Don't forget to append header (if you want)
      results.append(headers)
      return results
  
  
  def extract_header_count__from_summary_from_report_htmltestrunner():
      filename = (r"E:\test_runners 2 edit project\selenium_regression_test_5_1_1\TestReport\ClearCore501_Automated_GUI_TestReport.html")
      html_report_part = open(filename,'r')
      soup = BeautifulSoup(html_report_part, "html.parser")
      table = soup.select_one("#result_table")
  
      #Create list here...
      results = []
      for row in table.select("tr.passClass"):
          #Store row string in variable and append before printing
          row_str = " ".join([td.text for td in row.find_all("td")[1:-1]])
          results.append(row_str)
  #        print(row_str)
  
      return results
  
  def extract_testcases_from_report_htmltestrunner():
      filename = (r"E:\test_runners 2 edit project\selenium_regression_test_5_1_1\TestReport\ClearCore501_Automated_GUI_TestReport.html")
      html_report_part = open(filename,'r')
      soup = BeautifulSoup(html_report_part, "html.parser")
      for div in soup.select("#result_table tr div.testcase"):
            yield div.text.strip().encode('utf-8'), div.find_next("a").text.strip().encode('utf-8')
  </code></pre>
  
  <p>How can I include the return values from the functions into the email body?</p>