| 81 | return csv |
| 82 | |
| 83 | def send_email(body): |
| 84 | |
| 85 | server_ssl = smtplib.SMTP_SSL('smtp.gmail.com', 465) |
| 86 | server_ssl.ehlo() |
| 87 | |
| 88 | emailfrom = 'yb4coding@gmail.com' |
| 89 | emailto = 'yb4coding@gmail.com' |
| 90 | fileToSend = "all info.csv" |
| 91 | |
| 92 | username_mail = username |
| 93 | password_mail = password |
| 94 | msg = MIMEMultipart() |
| 95 | msg["From"] = emailfrom |
| 96 | msg["To"] = emailto |
| 97 | msg["Subject"] = "Spreadsheet of iPhones present in flipkart contating all information." |
| 98 | |
| 99 | |
| 100 | ctype, encoding = mimetypes.guess_type(fileToSend) |
| 101 | if ctype is None or encoding is not None: |
| 102 | ctype = "application/octet-stream" |
| 103 | |
| 104 | maintype, subtype = ctype.split("/", 1) |
| 105 | |
| 106 | if maintype == "text": |
| 107 | fp = open(fileToSend) |
| 108 | # Note: we should handle calculating the charset |
| 109 | attachment = MIMEText(fp.read(), _subtype=subtype) |
| 110 | fp.close() |
| 111 | else: |
| 112 | fp = open(fileToSend, "rb") |
| 113 | attachment = MIMEBase(maintype, subtype) |
| 114 | attachment.set_payload(fp.read()) |
| 115 | fp.close() |
| 116 | encoders.encode_base64(attachment) |
| 117 | attachment.add_header("Content-Disposition", "attachment", filename=fileToSend) |
| 118 | msg.attach(attachment) |
| 119 | |
| 120 | server = smtplib.SMTP("smtp.gmail.com:587") |
| 121 | server.starttls() |
| 122 | server.login(username_mail,password_mail) |
| 123 | server.sendmail(emailfrom, emailto, msg.as_string()) |
| 124 | server.quit() |
| 125 | |
| 126 | if __name__ == "__main__": |
| 127 | print('Creating dataframe') |