aws-pinpoint

How to send an email with a custom template using aws pinpoint


I'm trying to send a email with a template and a got this error message:

Unknown parameter in Content: "Template", must be one of: Simple, Raw

I followed this link: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/pinpoint-email.html#PinpointEmail.Client.send_email and this is my code:

client = boto3.client('pinpoint-email', region_name=AWS_REGION)

response = client.send_email(

    FromEmailAddress=SENDER,
    Destination={
        'ToAddresses': TOADDRESSES
    },
    Content={
        'Simple': {
            'Subject': {
                'Charset': CHARSET,
                'Data': "SUBJECT",
            },
            'Body': {
                'Html': {
                    'Charset': CHARSET,
                    'Data': "BODY_HTML"
                },
                'Text': {
                    'Charset': CHARSET,
                    'Data': "BODY_TEXT",
                }
            }
        },
        'Template': {
            'TemplateArn': TEMPLATE_ARN,
            'TemplateData': json.dumps(TEMPLATE_DATA)
        }
    }
)

Solution

  • Test using the SDK for Python (Boto 3) version 1.9.62 and Python version 3.6.7.