|
| 1 | +import os |
| 2 | +import json |
| 3 | + |
1 | 4 | from sendgrid import SendGridAPIClient |
2 | 5 | from sendgrid.helpers.mail import * |
3 | 6 |
|
|
8 | 11 |
|
9 | 12 | def build_hello_email(): |
10 | 13 | ## Send a Single Email to a Single Recipient |
11 | | - import os |
12 | | - import json |
13 | | - from sendgrid import SendGridAPIClient |
14 | | - from sendgrid.helpers.mail import Mail, From, To, Subject, PlainTextContent, HtmlContent, SendGridException |
15 | | - |
| 14 | + |
16 | 15 | message = Mail(from_email=From('from@example.com', 'Example From Name'), |
17 | 16 | to_emails=To('to@example.com', 'Example To Name'), |
18 | 17 | subject=Subject('Sending with SendGrid is Fun'), |
@@ -84,11 +83,8 @@ def get_mock_personalization_dict(): |
84 | 83 | return mock_pers |
85 | 84 |
|
86 | 85 | def build_multiple_emails_personalized(): |
87 | | - import json |
88 | | - from sendgrid.helpers.mail import Mail, From, To, Cc, Bcc, Subject, PlainTextContent, \ |
89 | | - HtmlContent, SendGridException, Personalization |
90 | | - |
91 | 86 | # Note that the domain for all From email addresses must match |
| 87 | + |
92 | 88 | message = Mail(from_email=From('from@example.com', 'Example From Name'), |
93 | 89 | subject=Subject('Sending with SendGrid is Fun'), |
94 | 90 | plain_text_content=PlainTextContent('and easy to do anywhere, even with Python'), |
@@ -117,6 +113,7 @@ def build_multiple_emails_personalized(): |
117 | 113 | def build_attachment1(): |
118 | 114 | """Build attachment mock. Make sure your content is base64 encoded before passing into attachment.content. |
119 | 115 | Another example: https://github.com/sendgrid/sendgrid-python/blob/HEAD/use_cases/attachment.md""" |
| 116 | + |
120 | 117 | attachment = Attachment() |
121 | 118 | attachment.file_content = ("TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNl" |
122 | 119 | "Y3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12") |
|
0 commit comments