|
10 | 10 | "rb", |
11 | 11 | ).read() |
12 | 12 |
|
13 | | -# Define the file attachment |
14 | | -attachment: resend.Attachment = { |
| 13 | +# Send email with local inline attachment |
| 14 | +local_attachment: resend.Attachment = { |
15 | 15 | "filename": "resend-wordmark-black.png", |
16 | 16 | "content": list(f), |
17 | 17 | "content_type": "image/png", |
18 | 18 | # This is the content ID that will be used in the HTML to reference the image |
19 | 19 | "inline_content_id": "my-test-image", |
20 | 20 | } |
21 | 21 |
|
22 | | -# Define the email parameters |
23 | | -params: resend.Emails.SendParams = { |
| 22 | +local_params: resend.Emails.SendParams = { |
24 | 23 | "from": "onboarding@resend.dev", |
25 | 24 | "to": ["delivered@resend.dev"], |
26 | | - "subject": "Inline attachment test from Resend's python SDK", |
27 | | - "html": '<p>This is an email with an <img width=100 height=40 src="cid:my-test-image" /> embed image</p>', |
28 | | - "attachments": [attachment], |
| 25 | + "subject": "Local inline attachment test from Resend's python SDK", |
| 26 | + "html": '<p>This email contains a local inline attachment: <img width=100 height=40 src="cid:my-test-image" /></p>', |
| 27 | + "attachments": [local_attachment], |
29 | 28 | } |
30 | 29 |
|
31 | | -email: resend.Email = resend.Emails.send(params) |
32 | | -print("Sent email with attachment") |
33 | | -print(email) |
| 30 | +local_email: resend.Email = resend.Emails.send(local_params) |
| 31 | +print("Sent email with local inline attachment") |
| 32 | +print(local_email) |
| 33 | + |
| 34 | +# Send email with remote inline attachment |
| 35 | +remote_attachment: resend.RemoteAttachment = { |
| 36 | + "filename": "remote-resend-wordmark-black.png", |
| 37 | + "path": "https://resend.com/static/brand/resend-wordmark-black.png", |
| 38 | + "inline_content_id": "my-test-image", |
| 39 | +} |
| 40 | + |
| 41 | +remote_params: resend.Emails.SendParams = { |
| 42 | + "from": "onboarding@resend.dev", |
| 43 | + "to": ["delivered@resend.dev"], |
| 44 | + "subject": "Remote inline attachment test from Resend's python SDK", |
| 45 | + "html": '<p>This email contains a remote inline attachment: <img width=100 height=40 src="cid:my-test-image" /></p>', |
| 46 | + "attachments": [remote_attachment], |
| 47 | +} |
| 48 | + |
| 49 | +remote_email: resend.Email = resend.Emails.send(remote_params) |
| 50 | +print("Sent email with remote inline attachment") |
| 51 | +print(remote_email) |
0 commit comments