Skip to main content

📧 Email Module Guide

This page is currently only available in Chinese. Please switch to 简体中文 for the full content.

📧 Email Module Guide

The Email module enables automatic sending and receiving of emails, with support for attachments, CC, mass sending and other advanced features.

Core Scenarios

Send a Simple Email

import office
office.email.send_email(
key='your_email_authorization_code',
msg_from='your@qq.com',
msg_to='target@qq.com',
msg_subject='Meeting Notice',
content='Meeting at 3 PM tomorrow.'
)

Send Email with Attachment

office.email.send_email(
key='your_email_authorization_code',
msg_from='your@qq.com',
msg_to='target@qq.com',
msg_subject='Weekly Report',
content='Please find attached this week\'s report.',
attach_files=['./report.pdf', './data.xlsx']
)

CC Multiple People

office.email.send_email(
key='your_email_authorization_code',
msg_from='your@qq.com',
msg_to='primary@qq.com',
msg_cc='cc1@qq.com, cc2@qq.com',
msg_subject='Project Meeting',
content='Meeting at 3 PM tomorrow.'
)

Receive Emails

office.email.receive_email(
key='your_email_authorization_code',
msg_from='your@qq.com',
msg_to='sender@qq.com',
output_path='./received_emails/',
status='UNSEEN'
)

Email Configuration

EmailhostPort
QQsmtp.qq.com465
163smtp.163.com465
Gmailsmtp.gmail.com587

⚠️ The key here is the authorization code, not the login password!

Full API see Email API Reference

AI 办公效率课
35 讲 AI 自动化办公实战课用 Python + AI 处理 Excel、Word、PDF、邮件等办公场景。
去学习