Commit 02d2dedd authored by Samy Haffoudhi's avatar Samy Haffoudhi

integration google sheets

parent ad080b5c
import os import os
import smtplib import smtplib
from email.message import EmailMessage from email.message import EmailMessage
from sheets import get_mails
EMAIL_ADDRESS = os.environ.get('EMAIL_USER') EMAIL_ADDRESS = os.environ.get('EMAIL_USER')
EMAIL_PASSWORD = os.environ.get('EMAIL_PASS') EMAIL_PASSWORD = os.environ.get('EMAIL_PASS')
...@@ -11,6 +12,9 @@ msg['From'] = EMAIL_ADDRESS ...@@ -11,6 +12,9 @@ msg['From'] = EMAIL_ADDRESS
msg['To'] = 'haffoudhisamy@gmail.com' msg['To'] = 'haffoudhisamy@gmail.com'
msg.set_content('test content') msg.set_content('test content')
adresses = get_mails()
print(adresses)
with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp: with smtplib.SMTP_SSL('smtp.gmail.com', 465) as smtp:
smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD) smtp.login(EMAIL_ADDRESS, EMAIL_PASSWORD)
......
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = ["https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/spreadsheets',"https://www.googleapis.com/auth/drive.file","https://www.googleapis.com/auth/drive"]
creds = ServiceAccountCredentials.from_json_keyfile_name("creds.json", scope)
client = gspread.authorize(creds)
sheet = client.open("test autoprospect").sheet1
def get_mails():
adresses = sheet.col_values(3)
return adresses
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment