Automation Scripts which is helpful for you to Automate Zapier. These Scripts are wirtten by Zapier Experts https://easyaiz.com/zapier-experts/ import gspread from oauth2client.service_account import ServiceAccountCredentials import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText
scope = ['https://spreadsheets.google.com/feeds', 'https://www.googleapis.com/auth/drive'] creds = ServiceAccountCredentials.from_json_keyfile_name('google_sheets_credentials.json', scope) client = gspread.authorize(creds)
sheet = client.open('Your Google Sheet Name').sheet1
data = sheet.get_all_records()
sender_email = "[email protected]" sender_password = "your_password" receiver_email = "[email protected]" subject = "Subject of the Email"
msg = MIMEMultipart() msg['From'] = sender_email msg['To'] = receiver_email msg['Subject'] = subject
email_body = "" for row in data: if row['Condition']: # Add your condition here email_body += f"Name: {row['Name']}, Email: {row['Email']}\n"
msg.attach(MIMEText(email_body, 'plain'))
try: server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login(sender_email, sender_password) text = msg.as_string() server.sendmail(sender_email, receiver_email, text) server.quit() print("Email sent successfully!") except Exception as e: print(f"Error: {e}")