import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from datetime import datetime, timedelta import pytz # For timezone handling def send_email(interviewee_email="darkicewolf50@gmail.com", interviewee_name="brock", date="10-1-2024", start_time="10:00 AM", location ="ENC25"): """ Sends an email notification to the interviewee and a static Gmail account. ``REQUIRES``: interviewee_email (str), interviewee_name (str), date (str), start_time (str) ``PROMISES``: Sends an email to interviewee and static email on successful appointment booking. """ # Define static email for notifications and Gmail credentials static_email = "uofcbaja.noreply@gmail.com" gmail_user = "uofcbaja.noreply@gmail.com" gmail_apppassword = "pver lpnt upjd zvld" # Define Mountain Standard Time mst = pytz.timezone("America/Edmonton") # MST with Daylight Savings considered # Parse the input date and time, localize to MST start_datetime = mst.localize(datetime.strptime(f"{date} {start_time}", "%Y-%m-%d %H:%M:%S")) end_datetime = start_datetime + timedelta(minutes=30) # Format date and time for the calendar URLs start_time_google = start_datetime.strftime("%Y%m%dT%H%M%S") # Google Calendar (Local time without Z) end_time_google = end_datetime.strftime("%Y%m%dT%H%M%S") # Google Calendar (Local time without Z) outlook_start = start_datetime.isoformat() # Outlook Calendar (ISO local time) outlook_end = end_datetime.isoformat() # Outlook Calendar (ISO local time) # Create message object msg = MIMEMultipart() msg['From'] = gmail_user msg['To'] = f"{interviewee_email}, {static_email}" msg['Subject'] = "Interview Appointment Confirmation" # Message body body = f'''
Dear {interviewee_name},
Your interview has been scheduled on {date} at {start_time} MST.
Your interview location is at {location} or will be emailed to you.
Please ensure to be available at the designated time.
Best regards,
UCalgary Baja Interview Team