El método de usar python para obtener por lotes múltiples archivos adjuntos de correo electrónico de Outlook
import os
import extract_msg
def read_fujian(file_name):
msg = extract_msg.Message(file_name)
"""
print(msg.subject)
print(msg.cc)
print(msg.bcc)
print(msg.sender)
print(msg.to)
print(msg.path)
print(msg.attachments)
print(msg.date)
print(msg.body)
print(msg.htmlBody)
"""
for attachment in msg.attachments:
attachment.save(customPath='./file')
def getFileName(path):
''' 获取指定目录下的所有指定后缀的文件名 '''
f_list = os.listdir(path)
for i in f_list:
if os.path.splitext(i)[1] == '.msg':
print(i)
read_fujian(i)
if __name__ == '__main__':
path = '.'
getFileName(path)