title: send excel attachment through outlook using python
body: <p>Below is the code i'm using to send excel as a attachment to outlook email using python 2.7 version. If i command the attachment lines in the code, i could send the text email but not the attached email.Also i'm not receiving any error. Can somebody please help me identify the issue in the code.</p>
  
  <pre><code>import psycopg2
  import pandas as pd
  import numpy as np
  import xlsxwriter
  from datetime import date
  from email.mime.multipart import MIMEMultipart
  from email.mime.text import MIMEText
  from email.mime.base import MIMEBase
  from email import encoders
  import smtplib
  import sys
  reload(sys)
  sys.setdefaultencoding('utf-8')
  
  server = smtplib.SMTP(host='xxxxx.net', port=25)
  fromaddr = "aaaaaaaaabb@outlook.com"
  RECIPIENTS = "aaaaaaaaabb@outlook.com"
  msg = MIMEMultipart()
  body = """
     Hi Team, &lt;br&gt;
     &lt;br&gt;
     Please find the attached data sync validation betweeen Reltio and BDS .&lt;br&gt;
     &lt;br&gt;
     Please reach out to Team for any questions.&lt;br&gt;
     &lt;br&gt;
     Regards,&lt;br&gt;
     xxxx &lt;br&gt;
     Support Team&lt;br&gt;"""
  
  subject = 'Reltio and BDS Data Sync for EU Org'
  msg = MIMEMultipart("alternative", None, [MIMEText(body, 'html','utf-8')])
  msg['To'] = RECIPIENTS
  msg['From'] = "axxxxxyyy@.net"
  msg['Subject'] = subject
  stg = MIMEBase('application', 'vnd.ms-excel')
  stg.set_payload(open("EU_Consent.xlsx", "rb").read())
  encoders.encode_base64(stg)
  stg.add_header('Content-Disposition', 'attachment', filename="EU_Consent.xlsx")
  msg.attach(stg)
  server.ehlo()
  server.starttls()
  server.ehlo()
  text = msg.as_string()
  server.sendmail(fromaddr, RECIPIENTS, text)
  server.quit()
  </code></pre>