导包
import datetime
from pathlib import Path
import pytz
from exchangelib import (
Configuration, Account, DELEGATE, Q,
Credentials, HTMLBody, Message, FileAttachment
)
from exchangelib.protocol import CachingProtocol
连接邮箱
server = 'example.com'
domain = 'domain.example.com'
username = 'your_username'
password = 'your_password'
address = 'your_email_address'
def outlook_login():
"""
连接Outlook邮箱
:return: 邮箱对象
"""
try:
config = Configuration(
server=server,
credentials=Credentials(f'{
domain}\\{
username}', password)
)