ERPNext Foundation ERPNext Cloud Chat Blog Discuss Frappé* Donate

[ Achieved ]Frappe.sendmail : Send email using scheduler with attachments

email
account
billing
customization
attachments

#1

Hello Community,

I am working on scheduler task in which i want to sent an email on every sunday to the customer whose payment ( Sales Invoice ) are Overdue.

I have done with auto emailing, but how can i attach file in email ?

Like if Customer A has 4 Overdue Invoice then i want to attach all 4 invoice in single mail with template.

Thanks,
Hardik Gadesha


#2

“I have done with auto emailing, but how can i attach file in email”

Good question! You will need to study the existing code, to then develop what you require.

For eg there’s this function https://github.com/frappe/frappe/blob/develop/frappe/email/email_body.py#L145

A search on ‘attach_file’ will give you pointers to learn from others?


#3

Thanks For your kind words @clarkej

I have achieved this feature :slight_smile:


#4

@Hardik_Gadesha sharing the steps may help fellow community developers

Regards,
@hereabdulla


#5

Yes Sure @hereabdulla

  1. Collect all Overdue Invoice which has status Overdue.
  2. Prepare Content for mail.
  3. Loop through all invoice and adjust all data in content.
  4. Fetch customer email id.
  5. Use frappe.sendmail to send mail.

I hope you got it. Will post detailed solution soon.