Skip to content

Commit 131bc62

Browse files
author
Rich Leland
committed
Add attachment to example code. Refs #62
1 parent 42eb39a commit 131bc62

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

examples/transmissions/a-file.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Woo hoo! This attachment was added via python-sparkpost.

examples/transmissions/send_transmission.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
1+
import os
2+
13
from sparkpost import SparkPost
24

5+
parent_dir = os.path.dirname(os.path.realpath(__file__))
6+
attachment_path = os.path.abspath(os.path.join(parent_dir, "a-file.txt"))
7+
38
sp = SparkPost()
49

510
response = sp.transmissions.send(
@@ -23,6 +28,13 @@
2328
},
2429
track_opens=True,
2530
track_clicks=True,
31+
attachments=[
32+
{
33+
"name": "test.txt",
34+
"type": "text/plain",
35+
"filename": attachment_path
36+
}
37+
],
2638
campaign='sdk example',
2739
metadata={
2840
'key': 'value',

0 commit comments

Comments
 (0)