I have been trying to write a code which could send mail automatically once the user select "send" from dropdown in google sheet. But I want to inform the user about the mails that are already send and this is my key that I want to do. So I decided to automatically change the value of send to Already send but I couldn't be able to do that. If you guys have better suggestions to inform user about the mails already send then it would be a great help.
SHEET_ID = "#######"
SHEET_NAME = "Sheet1"
URL = f"#########"
def load_df(url):
parse_dates = ["Date"]
df = pd.read_csv(url, parse_dates=parse_dates)
return df
def query_data_and_send_email(df):
present = date.today()
confirm_counter = 0
reached_counter = 0
for _, row in df.iterrows():
if (present == row["Date"].date()) and (row["Order Status"] == "Confirmed" and (row["Send Mail"] == "Send")):
#ezgmail.send(row["Email Address"], row["Order Number"], "Hip Hip Hooray!\n\nCongratulations you have great taste!\nWe are glad to confirm your order, will keep updating you\n\nCustomer Service")
confirm_counter += 1
#Send Mail column value change from send to Already sent automatically
elif (present == row["Date"].date()) and (row["Order Status"] == "Received At Destination" and (row["Send Mail"] == "Send")):
#ezgmail.send(row["Email Address"], row["Order Number"], "WOO HOO!\n\nYour Order is now shipped\nWe are super excited to reach you at the earliest!\n\nCustomer Service")
reached_counter += 1
return f"Confirmation mail send to: {confirm_counter} Reached At Destination Mail: {reached_counter}" ```