Skip to content

Commit d7d292c

Browse files
vmeseleshanholtz
andauthored
chore: Update mail_example.py (#1048)
Co-authored-by: Elise Shanholtz <eshanholtz@twilio.com>
1 parent 0b77438 commit d7d292c

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

examples/helpers/mail_example.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import os
2+
import json
3+
14
from sendgrid import SendGridAPIClient
25
from sendgrid.helpers.mail import *
36

@@ -8,11 +11,7 @@
811

912
def build_hello_email():
1013
## 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+
1615
message = Mail(from_email=From('from@example.com', 'Example From Name'),
1716
to_emails=To('to@example.com', 'Example To Name'),
1817
subject=Subject('Sending with SendGrid is Fun'),
@@ -84,11 +83,8 @@ def get_mock_personalization_dict():
8483
return mock_pers
8584

8685
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-
9186
# Note that the domain for all From email addresses must match
87+
9288
message = Mail(from_email=From('from@example.com', 'Example From Name'),
9389
subject=Subject('Sending with SendGrid is Fun'),
9490
plain_text_content=PlainTextContent('and easy to do anywhere, even with Python'),
@@ -117,6 +113,7 @@ def build_multiple_emails_personalized():
117113
def build_attachment1():
118114
"""Build attachment mock. Make sure your content is base64 encoded before passing into attachment.content.
119115
Another example: https://github.com/sendgrid/sendgrid-python/blob/HEAD/use_cases/attachment.md"""
116+
120117
attachment = Attachment()
121118
attachment.file_content = ("TG9yZW0gaXBzdW0gZG9sb3Igc2l0IGFtZXQsIGNvbnNl"
122119
"Y3RldHVyIGFkaXBpc2NpbmcgZWxpdC4gQ3JhcyBwdW12")

0 commit comments

Comments
 (0)