Quantcast
Channel: Active questions tagged email - Stack Overflow
Viewing all articles
Browse latest Browse all 29748

How to send an "array" with e-mail via python?

$
0
0

I want to send a mail with gmail. But mail must specifically include an array. I need help. Message part in the code block, specifically accept text type.

If I tell specifically my goal; I have a .csv file, and I'm creating random Sub Sample from this file. Sub Sample includes 5 rows. I created an array with this random rows and I want to send this random rows which type is array.

import pandas as pd
import smtplib

data = pd.read_csv("Words1.csv")
row1 = data.sample(n=5)
A = [row1]
print(A)
email = 'sender@gmail.com'  # Your email
password = 'senderpassword'  # Your email account password
send_to_email = 'receiver@gmail.com'  # Who you are sending the message to
message = 'A'  # The message in the email 

server = smtplib.SMTP('smtp.gmail.com', 587)  # Connect to the server
server.starttls()  # Use TLS
server.login(email, password)  # Login to the email server
server.sendmail(email, send_to_email, message)  # Send the email
server.quit()  # Logout of the email server

Thank you.


Viewing all articles
Browse latest Browse all 29748

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>