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

@ASHISH_JHA

you can use notification feature Notification

or else can write python side script for the same.

2 Likes

Thanks for the quick reply.I have to send mail to each customer when they complete 1 year with us. So after writing the python script for the same how should I integrate it with erpnext so that the mails will be sent.
I will do a cron that will run the python script once everyday and the script will send the mails to the desired customers but I donā€™t know where to write the cron.

you have to write cron in hooks, under scheduler events

1 Like

@Hardik_Gadesha In Notification, how do I specify an attachment to include in the email please?

@charleslcso

In notification you can see 1 Section Print Setting, there you can check filed Attach Print and select Print Format for attachment.

The attachment is dynamically uploaded via API POST to DocField ā€œdocument_infoā€. I canā€™t figure out how to use Attach Print for attaching the attachment using variable nameā€¦ Can you help more?

Screenshot 2022-07-14 at 4.08.33 PM

I did not get your use case here. can you please explain some more about it?

Hello @Hardik_Gadesha

I wonder how to use API POST to attach files to new Doc so that the attachments will appear under File Manager. Please see screen cap below.

Screenshot 2022-07-20 at 2.15.14 PM

Currently we managed to do the followings successfully:

  • DocField is either Attach, Attach Image or Long Text
  • base64encode png, jpg, pdf
  • API POST to create a new Doc, and populate the DocField with the base64encoded string

The base64encoded string will be displayed in the related DocFields. Please see screen cap:

Screenshot 2022-07-20 at 2.18.58 PM

The reason for the above is because I want to display images in an HTML email sent via Notification. Currently (stated above), the Notification is using this format:

Screenshot 2022-07-20 at 2.20.42 PM

I have 2 issues.

  1. DocField size is small. The image might be larger than 1MB, so API POST will result in a 500 Internal Server Error.

  2. gmail.com wonā€™t display base64 images.

Therefore, if we can API POST and ā€œattachā€ the attachments in the Doc, then in the Notification template we might be able to reference files in the File Manager using

< server >/files/< file >

Please see if you can help.