Good Afternoon all,
I’m having some novice problems with the email service
I wish to send an email an attach a csv which is exported from a table
I have tried the following and i have attempted to find the solution via the docs but coming up short.
any assistance please
my code:
file = app_tables.my_table.search()
file = email_csv.to_csv
email = anvil.media.from_file(file,‘text/csv’,‘Test File’)
anvil.email.send(
from_name = “Me”,
to = “myemail@email.com”,
attachments = email
)
If you can provide a clone-link, you will probably get more helpful responses. Also note you can wrap your code-blocks in ``` to format as code.
It looks like you are not calling the to_csv
method. Also, the object returned by to_csv
is a media object so the anvil.media.from_file
is not needed.
This is probably closer:
file = app_tables.my_table.search().to_csv()
anvil.email.send(
from_name = “Me”,
to = “myemail@email.com”,
attachments = file,
subject="my csv file"
)
Many thanks
That’s worked perfectly