Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hosted template and attachments #197

Open
ps-jf opened this issue May 6, 2020 · 1 comment
Open

Hosted template and attachments #197

ps-jf opened this issue May 6, 2020 · 1 comment

Comments

@ps-jf
Copy link

ps-jf commented May 6, 2020

I have code that works with an inline template and an attachment, and code that works with a hosted template and no attachment.

When I try to use the hosted template with an attachment it is not included. Why is this? Is there a way to have an attachment sent with a hosted template?

I have removed any credentials from the below combined cdoe which should use a hosted template and include the attachment:

from sparkpost import SparkPost
from sparkpost.exceptions import SparkPostAPIException

sparky = SparkPost("SPARKPOST_KEY")

response = sparky.transmissions.send(
            from_email={
                'email': sender,
                'name': "Test Name"
            },
            recipients=recipient,
            template=template_id,
            subject=subject_line,
            ip_pool='my_mailer',
            track_opens=True,
            track_clicks=True,
            use_draft_template=True,
            substitution_data={
                'SUBJECT': subject_line,
                'ADDRESSEE': addressee_string,
                'CONTENT_STRING': content_string,
                'SENDER': sender,
                'REPLY_TO': reply_to,
                'FROM_NAME': from_name
            },
            attachments=[
                {
                    'type': 'application/vnd.ms-excel',
                    'name': 'file1.xlsx',
                    'filename': 'file1.xlsx'
                }
            ]
        )

        print(response)
@rmorenobello
Copy link

rmorenobello commented Dec 31, 2021

If the documentation is up to date, it seems it's not implemented yet.

Attachments Support in the Transmissions API
We have added support for attachments using the Transmissions API. Attachments can be any file type or inline images. In a future enhancement, we will include file type validation.

A few notes about this feature:

There is a 20 MB content size limit on each message, including content body and all attachments
Attachments are supported with inline templates only. We may include support for attachments with stored templates in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants