python 如何将邮件移动到 Outlook 中的另一个文件夹

How I can move messages to another folder in Outlook in python

我想用我的 python 脚本将我的邮件移动到一个子文件夹中。

不幸的是,move命令无法按我想要的方式运行。

有什么建议吗?

这是我提到的代码:

for message in testing.get_messages():
    print(message)
    if message.subject is not None and '<noticket>' in message.subject:
        message.mark_as_read()
        message.move('Inbox/Testing/NoTicket')
    else:
        print ("Checking...")
        message.move('Inbox/Testing/Processed')

我使用 O365 作为 Python 包。

来自 Microsoft Graph 资源管理器的错误消息:

{
    "error": {
        "code": "ErrorInvalidUser",
        "message": "The requested user 'testmail@testmail.com' is invalid.",
        "innerError": {
            "date": "2021-06-23T16:59:42",
            "request-id": "...",
            "client-request-id": "..."
        }

我找到了解决问题的方法:)

processed = testing.get_folder(folder_name='Processed')
for message in testing.get_messages():
    print(message)
    if message.subject is not None and '<noticket>' in message.subject:
        message.mark_as_read()
    else:
        print ("Checking...")
        print(message.move)
        message.move(processed)