Skip to content

Commit 9793a6a

Browse files
committed
Clean up messages and hello example.
1 parent ffea76d commit 9793a6a

2 files changed

Lines changed: 16 additions & 32 deletions

File tree

python/example_code/sesv2/attachments_scenario/scenario_sesv2_email_attachments.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class SESv2EmailAttachmentsScenario:
3434
"""
3535
Demonstrates sending emails with attachments using Amazon SESv2.
3636
37-
This scenario walks through:
37+
This scenario demonstrates:
3838
1. Setting up an email identity and template.
3939
2. Sending a simple email with a file attachment.
4040
3. Sending a simple email with an inline image.
@@ -56,11 +56,11 @@ def __init__(self, sesv2_wrapper: SESv2Wrapper) -> None:
5656
def run_scenario(self) -> None:
5757
"""Runs the SESv2 email attachments scenario."""
5858
print("-" * 88)
59-
print("Welcome to the Amazon SESv2 Email Attachments Scenario!")
59+
print("Welcome to the Amazon SESv2 Email Attachments Scenario.")
6060
print("-" * 88)
6161
print(
6262
"This scenario demonstrates how to send emails with attachments\n"
63-
"using the new SESv2 attachment support. SES handles MIME\n"
63+
"using SESv2 attachment support. SES handles MIME\n"
6464
"construction automatically, so you don't need to build raw\n"
6565
"MIME messages.\n"
6666
)
@@ -199,7 +199,7 @@ def _step1_send_email_with_attachment(self) -> None:
199199
attachments=[attachment],
200200
)
201201

202-
print(f" Email sent! MessageId: {message_id}")
202+
print(f" Email sent. MessageId: {message_id}")
203203
print(
204204
" SES automatically constructed the MIME message with the "
205205
"attachment.\n"

python/example_code/sesv2/attachments_scenario/sesv2_hello.py

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -24,42 +24,26 @@ def hello_sesv2(sesv2_client):
2424
2525
:param sesv2_client: A Boto3 SESv2 client object.
2626
"""
27-
print("Hello, Amazon SESv2! Let's list your email identities:\n")
27+
print("Hello, Amazon SESv2. Let's list up to 5 email identities:\n")
2828

29-
identity_count = 0
30-
next_token = None
3129
try:
32-
while True:
33-
kwargs = {"PageSize": 20}
34-
if next_token:
35-
kwargs["NextToken"] = next_token
36-
response = sesv2_client.list_email_identities(**kwargs)
37-
identities = response.get("EmailIdentities", [])
38-
for identity in identities:
39-
identity_count += 1
40-
identity_name = identity.get("IdentityName", "Unknown")
41-
identity_type = identity.get("IdentityType", "Unknown")
42-
verification_status = identity.get(
43-
"VerificationStatus", "Unknown"
44-
)
45-
sending_enabled = identity.get("SendingEnabled", False)
46-
print(
47-
f" Identity: {identity_name}"
48-
f" Type: {identity_type}"
49-
f" Status: {verification_status}"
50-
f" Sending: {'Enabled' if sending_enabled else 'Disabled'}"
51-
)
52-
next_token = response.get("NextToken")
53-
if not next_token:
54-
break
30+
response = sesv2_client.list_email_identities(PageSize=5)
31+
identities = response["EmailIdentities"]
5532

56-
if identity_count == 0:
33+
if not identities:
5734
print(
5835
"No email identities found. "
5936
"Use CreateEmailIdentity to add one."
6037
)
6138
else:
62-
print(f"\nFound {identity_count} email identity(ies).")
39+
for identity in identities:
40+
print(
41+
f" Identity: {identity['IdentityName']}"
42+
f" Type: {identity['IdentityType']}"
43+
f" Status: {identity['VerificationStatus']}"
44+
f" Sending: {'Enabled' if identity['SendingEnabled'] else 'Disabled'}"
45+
)
46+
print(f"\nShowing {len(identities)} email identity(ies).")
6347

6448
except ClientError as err:
6549
logger.error(

0 commit comments

Comments
 (0)