Kyle Miller Posted November 11 Posted November 11 The docstring for sending an email attachment is as follows: >>> import base64 >>> from seeq.spy.notifications import send_email, EmailAttachment >>> send_email(to="test@seeq.com", >>> subject="Email with attachment", >>> content="See attachment", >>> attachments=EmailAttachment(content=base64.b64encode(b"My message attachment").decode("ascii"), >>> type="text/plain", >>> filename="attachment.txt")) But it's likely that you will want to send an actual file and not a trivial sentence like 'My message attachment.' You can't just jam a dataframe into the content parameter, so you need to hack it by encoding your dataframe first. See attached image for my code, which goes something like this: csv_content = df.to_csv().encode() And then your content parameter is base64.b64encode(csv_content).decode('ascii') NOTE: You need Seeq to enable your ability to send email attachments before you can even do this. And as of this writing, 'application/pdf' is the only value that works for the type parameter.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now