Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def generateHTML(CustomerID, MatchID):
- import time
- import re
- from FetchDetails import FetchMatchDetails
- from FetchDetails import FetchDetails
- from EmailSending import emailserver
- dateTime = str((time.strftime("%H%M")) + (time.strftime("%d%m")))
- fileName = str(CustomerID)+str(MatchID)+".html"
- file = open(fileName, "w")
- MatchDetails = FetchCarDetails(MatchID)
- CustomerDetails = FetchDetails(CustomerID)
- file.write(html)
- file.close
- emailserver(fileName, str(CustomerID)+".jpg", str(CustomerDetails[1]).replace("(","").replace("'","").replace(",","").replace(")",""))
- import smtplib
- from email.mime.multipart import MIMEMultipart
- from email.mime.base import MIMEBase
- from email.mime.text import MIMEText
- from email import encoders
- import winsound
- def emailserver(filename, imagename, to):
- try:
- username = str('########')
- password = str("######")
- msg = MIMEMultipart()
- msg['From'] = username
- msg['To'] = to
- msg['Subject'] = "We've matched you!"
- msg.attach(MIMEText("Please find details of your match below. \n Contact us to discuss this match further."))
- part = MIMEBase('application', 'octet-stream')
- part.set_payload(open(filename, 'rb').read())
- encoders.encode_base64(part)
- part.add_header('Content-Disposition',
- 'attachment; filename="%s"' % (filename))
- msg.attach(part)
- part1 = MIMEBase('application', 'octet-stream')
- part1.set_payload(open(imagename, 'rb').read())
- encoders.encode_base64(part1)
- part1.add_header('Content-Disposition',
- 'attachment; filename="%s"' % (imagename))
- msg.attach(part1)
- mailServer = smtplib.SMTP('smtp.mail.yahoo.com', 587)
- mailServer.ehlo()
- mailServer.starttls()
- mailServer.ehlo()
- mailServer.login(username, password)
- mailServer.sendmail(username, to, msg.as_string())
- frequency = 2000
- duration = 500
- winsound.Beep(frequency, duration)
- mailServer.close()
- except:
- return "Email Invalid"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement