Skip to content

Commit

Permalink
correctly send attachment with email
Browse files Browse the repository at this point in the history
  • Loading branch information
zandre-eng committed Dec 12, 2024
1 parent adf92e0 commit d1eb95d
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions corehq/apps/hqwebapp/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.core.mail.message import EmailMessage
from django.core.management import call_command
from django.urls import reverse
from django.template.defaultfilters import linebreaksbr
from django.utils.translation import gettext as _

from celery.exceptions import MaxRetriesExceededError
Expand Down Expand Up @@ -314,6 +315,7 @@ def send_domain_ucr_data_info_to_admins():
@periodic_task(run_every=crontab(minute=0, hour=1, day_of_month=1))
def send_stale_case_data_info_to_admins():
from corehq.apps.hqadmin.reports import StaleCasesTable
from corehq.apps.hqwebapp.tasks import send_html_email_async

if not settings.SOLUTIONS_AES_EMAIL or settings.SERVER_ENVIRONMENT != 'production':
return
Expand Down Expand Up @@ -354,9 +356,9 @@ def send_stale_case_data_info_to_admins():
'\nPlease note that an error occurred while compiling the report '
'and so there may be missing data that was not compiled.'
)
send_mail_async.delay(
send_html_email_async.delay(
subject,
message,
recipient_list=[settings.SOLUTIONS_AES_EMAIL],
filename=csv_file
recipient=settings.SOLUTIONS_AES_EMAIL,
html_content=linebreaksbr(message),
file_attachments=[csv_file]
)

0 comments on commit d1eb95d

Please sign in to comment.