能否下载AWS SES发送邮件的使用统计?支持Excel/API获取元数据吗?
Hey there! Let's tackle your questions about exporting AWS SES email delivery stats and accessing that metadata via API—this is a common ask, so I’ve got you covered:
能否导出Excel格式的已发送邮件元数据?
AWS SES doesn’t offer a direct "export to Excel" option in the console, but it’s easy to work around this:
- Quick fix via console: You can export your send history as a CSV file, which Excel can natively open and save as an XLSX/Excel format. The CSV includes all the metadata you care about: recipient email, subject line, send timestamp, delivery status, and more.
- Custom Excel export via API: Pull the data programmatically, then process it into Excel format using tools like Python’s Pandas (I’ll share an example below).
具体获取方式:控制台 vs API
1. 控制台操作(快速导出CSV转Excel)
- Head to the AWS SES Console, navigate to Delivery Insights > Message Search.
- Set your desired time range, filter by send status (if needed), then click the Export button. This generates a CSV file with your requested metadata.
- Open the CSV in Excel, then go to
File > Save Asand choose an Excel format (like .xlsx) to convert it.
2. API获取(programmatically access metadata)
If you need to automate this or integrate with other tools, SES v2 API has you covered with the ListSendEvents endpoint—it returns detailed metadata for individual sent emails.
Example Python code (using boto3)
This snippet pulls the last 7 days of send events, extracts the metadata you want, and exports it directly to Excel:
import boto3 from datetime import datetime, timedelta import pandas as pd # Initialize SES v2 client ses_client = boto3.client('sesv2', region_name='us-east-1') # Fetch send events from the last 7 days response = ses_client.list_send_events( StartTime=datetime.utcnow() - timedelta(days=7), EndTime=datetime.utcnow(), MaxItems=100 # Adjust based on your needs; paginate for larger datasets ) # Extract relevant metadata email_records = [] for event_batch in response['SendEvents']: for msg_event in event_batch['MessageEvents']: email_records.append({ 'Recipient Email': msg_event['Destination'], 'Email Subject': msg_event['Message']['Subject'], 'Send Timestamp': msg_event['Timestamp'], 'Delivery Status': msg_event['EventType'] }) # Convert to DataFrame and export to Excel df = pd.DataFrame(email_records) df.to_excel('ses_sent_emails_metadata.xlsx', index=False)
Key notes for API usage:
ListSendEventsonly retains data for 14 days max. For long-term storage, set up SES Event Publishing to send event data to S3, SQS, or CloudWatch Logs. You can then query S3 data with Athena and export results, or process it into Excel later.- Ensure your IAM role/user has the
ses:ListSendEventspermission (plus S3 permissions if using event publishing).
Bonus: Long-term metadata storage
If you need to keep send metadata beyond 14 days, configure SES Event Publishing to dump events to an S3 bucket. This lets you:
- Store data indefinitely (per your S3 lifecycle rules)
- Use tools like Athena to query and filter historical data
- Export query results as CSV/Excel directly from Athena
内容的提问来源于stack exchange,提问作者nnay84

