Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Sendgrid dynamic templating

import os
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail

message = Mail(
    from_email='from_email@example.com',
    to_emails='to@example.com',
    html_content='<strong>and easy to do anywhere, even with Python</strong>')
message.dynamic_template_data = {
    'subject': 'Testing Templates',
    'name': 'Some One',
    'city': 'Denver'
}
message.template_id = 'd-f43daeeaef504760851f727007e0b5d0'
try:
    sendgrid_client = SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))
    response = sendgrid_client.send(message)
    print(response.status_code)
    print(response.body)
    print(response.headers)
except Exception as e:
    print(e.message)
Comment

PREVIOUS NEXT
Code Example
Python :: sample hyperparameter tuning with grid search cv 
Python :: are logN and (lognN) same 
Python :: Label enconding code with sklearn 
Python :: global var in python 
Python :: linkedlist python 
Python :: pd.cut in pandas 
Python :: sorted multiple keys python 
Python :: stemming words python 
Python :: field in django 
Python :: Math Module cos() Function in python 
Python :: python increment by 1 
Python :: create django object 
Python :: UserWarning: X does not have valid feature names, but LinearRegression was fitted with feature names 
Python :: .squeeze function in numpy 
Python :: heroku how to access config vars django 
Python :: how to run python on ios 
Python :: python pandas how to access a column 
Python :: list vs tuple 
Python :: python 2d array 
Python :: what is the django orm 
Python :: how to replace a character of a string 
Python :: principal component analysis (pca) 
Python :: django-multivaluedictkeyerror-error 
Python :: concatenate strings and int python 
Python :: python unicode point to utf8 string 
Python :: dictionary get all values 
Python :: how to activate venv python 
Python :: pytest use fixture without running any tests 
Python :: minmax python 
Python :: self.assertequal python 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =