how to print the html file content as a body of the email message using python? -


matches = [] root, dirnames, filenames in os.walk('c:\users\top\udi\new folder'):     filename in fnmatch.filter(filenames, '*.html'):         matches.append(os.path.join(root, filename))         filename = root.rstrip(os.sep) + os.sep+ filename         #print filename          fromaddress = 'ucm_embed_test'         toaddress = "hetappa@ace.com, hepa@gmail.com"         text = "test parsed"          msg = mimemultipart('alternative')         msg['from'] =fromaddress         msg['to'] = toaddress         msg['subject'] = text          print "sending mail"         ctype, encoding = mimetypes.guess_type(filename)         if ctype none or encoding not none:             ctype = "application/octet-stream"         maintype, subtype = ctype.split("/", 1)          open(filename) fp:             attachment = mimetext(fp.read(), _subtype=subtype)         attachment.add_header("content-disposition", "attachment",\                               filename=os.path.basename(filename))          msg.attach(mimetext(open(filename).read(), "text/html"))         server = smtplib.smtp('eu-smtp.nuae.com')         server.ehlo()         #server.starttls()         #server.login(username,password)         server.sendmail(fromaddress,toaddress.split(','),msg.as_string())         server.quit() 

i reading .html file , later sending email respective person. message body appeared in email in form of html tags. how represent answers characters in message body. can me in ?


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -