Weekly auto email

I want to send auto emails weekly but it is not working. The below part of code gets triggered every monday and sends email after every 1 hour.Please help I am new to erpnext.

def send_daily():
‘’‘Check reports to be sent daily’‘’
current_day = calendar.day_name[now_datetime().weekday()]
now = frappe.utils.now_datetime()
current_time = now.strftime(“%H”)
enabled_reports = frappe.get_all(‘Auto Email Report’,
filters={‘enabled’: 1, ‘frequency’: (‘in’, (‘Daily’, ‘Weekdays’, ‘Weekly’))})

    for report in enabled_reports:
            auto_email_report = frappe.get_doc('Auto Email Report', report.name)

            # if not correct weekday, skip
            if auto_email_report.frequency == "Weekdays":
                    if current_day in ("Saturday", "Sunday"):
                            continue
            elif auto_email_report.frequency == 'Weekly':
                    if auto_email_report.day_of_week != current_day:
                            if auto_email_report.schedule_time != current_time:
                                    continue
            elif auto_email_report.frequency == "Daily":
                    if auto_email_report.schedule_time != current_time:
                            continue

            auto_email_report.send()

Why don’t use ‘Auto Email Report’ and set the frequency to ‘Weekly’ instead of creating your own method? I guess you have a bug in your scheduler if it isn’t working normally.
when do you trigger this code, is it in a hook?

@mel_erp thank you for your reply. I need to check it from my lead.I haven’t been informed anything about this.I was just informed to make changes in the code file.
I have untick the enabled checkbox,set frequency as weekly and schedule time as 10.But whenever i tick the enabled checkbox it gets triggered after every 1 hour on monday.

to my knowledge, this is the right behavior: if enabled, it will send an email during the night around 1 AM on Monday (or other days, depending on the config).
If you want to modify this behavior, let’s say you want the email to send at 8 AM, then you should NOT modify the code directly. Use a hook/override that code in your own app.

“Use a hook/override that code in your own app.” Please tell me how this needs to be done.I am new to erpnext and not aware about this.

@mel_erp I have made the following changes.I checked the indentation, it is correct but still getting error.I am facing the error on
schedule.every().monday.at(‘10:00’).do(send_daily) line.Please help

    for report in enabled_reports:
            auto_email_report = frappe.get_doc('Auto Email Report', report.name)

            # if not correct weekday, skip
            if auto_email_report.frequency == "Weekdays":
                    if current_day in ("Saturday", "Sunday"):
                            continue
            elif auto_email_report.frequency == 'Weekly':
                    schedule.every().monday.at('10:00').do(send_daily)
                            continue

            auto_email_report.send()

unfortunately, I’ve never seen that line before…