| import pandas as pd | |
| # import smtplib | |
| # import ssl | |
| import os | |
| # from email.mime.text import MIMEText | |
| # from email.mime.multipart import MIMEMultipart | |
| # from sendgrid import SendGridAPIClient | |
| # from sendgrid.helpers.mail import Mail | |
| from dotenv import load_dotenv | |
| from datetime import datetime, timedelta | |
| load_dotenv() | |
| class Schedule: | |
| def __init__(self): | |
| # Email server configuration commented out | |
| # self.server = "smtp.gmail.com" | |
| # self.port = 587 | |
| # self.sender = "axionai101@gmail.com" | |
| # self.password = os.getenv("app_password") | |
| pass | |
| def defaults(self,start_date,start_time,slot_length): | |
| self.date = start_date | |
| self.time = start_time | |
| self.slot_length = slot_length | |
| def schedule_slots(self, file_path): | |
| self.df = pd.read_csv(file_path) | |
| # Combine date and time into datetime object | |
| start_datetime = datetime.strptime( | |
| f"{self.date} {self.time}", "%Y-%m-%d %H:%M" | |
| ) | |
| slots = [] | |
| for i in range(len(self.df)): | |
| slot_start = start_datetime + timedelta(minutes=i * self.slot_length) | |
| slot_end = slot_start + timedelta(minutes=self.slot_length) | |
| slot_str = f"{slot_start.strftime('%Y-%m-%d %H:%M')} - {slot_end.strftime('%H:%M')}" | |
| slots.append(slot_str) | |
| self.df["Slot"] = slots | |
| # Function to send interview emails - COMMENTED OUT | |
| def send_emails(self): | |
| # Email sending functionality disabled | |
| print(f"Email sending disabled. Would have sent {len(self.df)} interview invitations.") | |
| return True # Return success for compatibility | |
| # Original email sending code commented out: | |
| # SENDGRID_API_KEY = os.getenv("SendGrid_Secret") | |
| # SENDER_EMAIL = os.getenv("EMAIL") # Verified sender email in SendGrid | |
| # if not SENDGRID_API_KEY or not SENDER_EMAIL: | |
| # logging.error("SendGrid API key or sender email not set in environment variables.") | |
| # return | |
| # sg_client = SendGridAPIClient(SENDGRID_API_KEY) | |
| # print("Starting SendGrid email sending") | |
| # for _, row in candidates.iterrows(): | |
| # recipient_email = row['Email'] | |
| # name = row['Name'] | |
| # interview_date = row["alloted"][:10].strip() | |
| # interview_time = row["alloted"][10:].strip() | |
| # unique_id = datetime.now().strftime("%Y%m%d%H%M%S") | |
| # subject = f"Your Interview at WeHack is Scheduled π [Ref: {unique_id}]" | |
| # # Customize the email HTML content as needed | |
| # body = f""" | |
| # <html> | |
| # <body> | |
| # <p>Dear {name},</p> | |
| # <p>We are pleased to inform you that, following a review of your application, | |
| # you have been selected to proceed to the next stage of the hiring process at <b>WeHack</b>.</p> | |
| # <p><b>Date:</b> {interview_date}<br> | |
| # <b>Time:</b> {interview_time}<br> | |
| # <b>Mode:</b> Will be contacted further</p> | |
| # <p>This interview presents an excellent opportunity for us to further explore your qualifications, | |
| # experiences, and interest in the position. We are eager to learn more about you and how you envision contributing to our team.</p> | |
| # <p>Please ensure your availability at the scheduled time. Should you have any questions, need to reschedule, | |
| # or require assistance, do not hesitate to contact us.</p> | |
| # <p>We look forward to our conversation and appreciate your continued interest in joining <b>WeHack</b>.</p> | |
| # <p> </p> <!-- Invisible space to prevent auto-quoting --> | |
| # <p>Kind regards,<br> | |
| # HR<br> | |
| # WeHack Organization<br> | |
| # [Contact Information]</p> | |
| # </body> | |
| # </html> | |
| # """ | |
| # message = Mail( | |
| # from_email=SENDER_EMAIL, | |
| # to_emails=recipient_email, | |
| # subject=subject, | |
| # html_content=body | |
| # ) | |
| # try: | |
| # response = sg_client.send(message) | |
| # if 200 <= response.status_code < 300: | |
| # print(f"β Email sent to {name} ({recipient_email})") | |
| # # Add event to calendar only after successful email | |
| # add_event_to_calendar(name, recipient_email, interview_date, interview_time, slot) | |
| # else: | |
| # logging.error(f"Failed to send email to {recipient_email}, status code: {response.status_code}") | |
| # except Exception as e: | |
| # logging.error(f"Exception while sending email to {recipient_email}: {e}") | |
| # time.sleep(2) # avoid rate limiting | |
| # print("β All emails have been sent successfully!") | |