I am emailing the content of a text file "gerrit.txt" @ http://pastie.org/8289257 in outlook using the below code, however after the email is sent when I look at the source code( @http://pastie.org/8289379) of the email in outlook ,i see unnecessary exclamation markds(!)'s in the code which is messing up the output, can anyone provide inputs on why is it so and how to avoid this ?
from email.mime.text import MIMEText
from smtplib import SMTP
def email (body,subject):
msg = MIMEText("%s" % body, 'html')
msg['Content-Type'] = "text/html; charset=UTF8"
msg['Subject'] = subject
s = SMTP('localhost',25)
s.sendmail('[email protected]', ['[email protected]'],msg=msg.as_string())
def main ():
# open gerrit.txt and read the content into body
with open('gerrit.txt', 'r') as f:
body = f.read()
subject = "test email"
email(body,subject)
print "Done"
if __name__ == '__main__':
main()
msg.as_string()
part and verify that no exclamation marks are present, for a start. – Sanjay