Internal server error when sending email attachment

Hi all,

I’m sending an email attachment using the Email service and getting:

anvil.server.InternalError: Internal server error: e26a46f97837
at /downlink/anvil/_threaded_server.py, line 295
  called from /downlink/anvil/server.py, line 35
  called from /downlink/anvil/email.py, line 17
  called from ServerModule1, line 42
  called from Form1, line 17

the code to send the email is:

anvil.email.send(from_name="Attendance Application", 
         to='my_email@gmail.com',
         subject='test',
         text='test',
         attachments=[anvil.BlobMedia("text/plain", "Text file contents")])

This works without the attachment.

Any help is appreciated.

Looks like the email won’t send if the BlobMedia doesn’t have a name. If you do

anvil.email.send(from_name="Attendance Application", 
         to='my_email@gmail.com',
         subject='test',
         text='test',
         attachments=[
           anvil.BlobMedia(
             "text/plain", "Text file contents", name="test.txt")
         ]
)

Then it should work.

I’m sorry the error message wasn’t exactly clear! I’ll raise a ticket in our issue tracker to improve it. We’ll consider randomly generating names as well.

No problem. Thanks Shaun! As you probably know, the code chunk I used was straight from the email docs in the Services menu and so perhaps name could be added there for clarity.

Thanks again.

1 Like