sendgrid

Python sendgrid library error when run from command line

Python sendgrid library error when run from command line Question: I have a sendgrid account set up and I can use it to send emails through python. When I run it in my spyder IDE it works great, but when run through the windows CMD i get <urlopen error unknown url type: https>. I tried …

Total answers: 1

Python Sendgrid send email with PDF attachment file

Python Sendgrid send email with PDF attachment file Question: I’m trying to attach a PDF file to my email sent with sendgrid. Here is my code : sg = sendgrid.SendGridAPIClient(apikey=os.environ.get(‘SENDGRID_API_KEY’)) from_email = Email(“[email protected]”) subject = “subject” to_email = Email(“[email protected]”) content = Content(“text/html”, email_body) pdf = open(pdf_path, “rb”).read().encode(“base64”) attachment = Attachment() attachment.set_content(pdf) attachment.set_type(“application/pdf”) attachment.set_filename(“test.pdf”) attachment.set_disposition(“attachment”) attachment.set_content_id(number) …

Total answers: 5