I am wondering if it’s possible to send an Anvil form as an email?
Basically, I have an Anvil form that represents a daily report. I now want to send this to users by email. I could PDF it using anvil.pdf.render_form
, but I’d much rather have the html content of the email just be the same content as the Anvil form, vs sending it as an attachment.
Anyone have any ideas for how to achieve this? I’m imaginging a function like render_form_as_html
…
There are (at least) two problems with embedding a form in an email:
- In order to render a form you need the app running
- Different email clients (gmail, outlook, etc.) render HTML in different ways
I’ve recently seen posts about getting a snapshot from a form. You could try that route, but even embedding images in an email often leads to different results in different clients.
For example, I receive the release notification emails from Anvil both in Outlook and gmail, and they look completely different.
I always put a very short summary in the email: I build a string with very simple HTML, so the chances of having a consistent rendering across clients are higher.
Then I add links to the app: I use the routing module from Anvil Extras, but you can use the hash routing that comes with Anvil, or the new server routing recently released, so by clicking on the email link one sees the form rendered by the app.
Here is a snapshot from an email I just received, with 3 links to 2 different apps:

And then there are the folks who have HTML turned OFF in their email program…