i have a variable which contain the template code like
template = '''
<html>
<div>
Hello world
</div>
</html>
'''
i want to generate a pdf and attach file with the sendgrid code below
import os
from sendgrid import SendGridAPIClient
template = '''
<html>
<div>
Hello world
</div>
</html>
message = {
'personalizations': [
{
'to': [
{
'email': '[email protected]'
}
],
'subject': 'Sending with Twilio SendGrid is Fun'
}
],
'from': {
'email': '[email protected]'
},
'content': [
{
'type': 'text/plain',
'value': template
}
]
}
try:
sg = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
response = sg.send(message)
print(response.status_code)
print(response.body)
print(response.headers)
except Exception as e:
print(str(e))
currently i have created a template of invoice and now i want to know how to generate a pdf with that template and attach that pdf file with the email
my template code is too lengthy so im not including it here