-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsend_emails.py
31 lines (25 loc) · 972 Bytes
/
send_emails.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
from pathlib import Path
from gmail_api import init_gmail_service, send_email
# Configuration
client_file = 'client_secret.json'
email_identifier = '[email protected]' # Change this for each account
# Initialize Gmail API service for the specific email account
service = init_gmail_service(client_file, prefix=f'_{email_identifier}')
# Email details
to_address = '[email protected]'
email_subject = 'MCP servers document'
email_body = 'This is a test email sent using the Gmail API.'
# Attachments
attachment_dir = Path('C:\\Users\\harsh\\Downloads\\MS projects\\MCP\\mcpdocs')
attachment_files = list(attachment_dir.glob('*')) # Load all files from the attachments folder
# Send the email
response_email_sent = send_email(
service=service,
to=to_address,
subject=email_subject,
body=email_body,
body_type='plain',
attachment_paths=attachment_files
)
# Output response
print(response_email_sent)