Advertisement
Guest User

Untitled

a guest
Mar 28th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. def generateHTML(CustomerID, MatchID):
  2. import time
  3. import re
  4. from FetchDetails import FetchMatchDetails
  5. from FetchDetails import FetchDetails
  6. from EmailSending import emailserver
  7. dateTime = str((time.strftime("%H%M")) + (time.strftime("%d%m")))
  8. fileName = str(CustomerID)+str(MatchID)+".html"
  9. file = open(fileName, "w")
  10. MatchDetails = FetchCarDetails(MatchID)
  11. CustomerDetails = FetchDetails(CustomerID)
  12. file.write(html)
  13. file.close
  14. emailserver(fileName, str(CustomerID)+".jpg", str(CustomerDetails[1]).replace("(","").replace("'","").replace(",","").replace(")",""))
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23. import smtplib
  24. from email.mime.multipart import MIMEMultipart
  25. from email.mime.base import MIMEBase
  26. from email.mime.text import MIMEText
  27. from email import encoders
  28. import winsound
  29. def emailserver(filename, imagename, to):
  30. try:
  31. username = str('########')
  32. password = str("######")
  33. msg = MIMEMultipart()
  34.  
  35. msg['From'] = username
  36. msg['To'] = to
  37. msg['Subject'] = "We've matched you!"
  38.  
  39. msg.attach(MIMEText("Please find details of your match below. \n Contact us to discuss this match further."))
  40.  
  41. part = MIMEBase('application', 'octet-stream')
  42. part.set_payload(open(filename, 'rb').read())
  43. encoders.encode_base64(part)
  44. part.add_header('Content-Disposition',
  45. 'attachment; filename="%s"' % (filename))
  46. msg.attach(part)
  47.  
  48. part1 = MIMEBase('application', 'octet-stream')
  49. part1.set_payload(open(imagename, 'rb').read())
  50. encoders.encode_base64(part1)
  51. part1.add_header('Content-Disposition',
  52. 'attachment; filename="%s"' % (imagename))
  53. msg.attach(part1)
  54.  
  55. mailServer = smtplib.SMTP('smtp.mail.yahoo.com', 587)
  56. mailServer.ehlo()
  57. mailServer.starttls()
  58. mailServer.ehlo()
  59. mailServer.login(username, password)
  60. mailServer.sendmail(username, to, msg.as_string())
  61. frequency = 2000
  62. duration = 500
  63. winsound.Beep(frequency, duration)
  64. mailServer.close()
  65. except:
  66. return "Email Invalid"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement