[Python] Gov system: How to fix com_error: (-2147467259, 'Unspecified error', None, None)

Discussão em 'Python' iniciado por Stack, Janeiro 27, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to programmatically cycle through my emails using python using win32com.client.

    import win32com.client
    import os
    from datetime import datetime, timedelta

    outlook = win32com.client.Dispatch('outlook.application')
    mapi = outlook.GetNamespace("MAPI")

    for account in mapi.Accounts:
    print(account.DeliveryStore.DisplayName)

    for idx, folder in enumerate(mapi.Folders("email@mail.com").Folders):
    print(idx+1, folder)

    messages = mapi.Folders("email@mail.com").Folders("Inbox").Items

    print([message.Body for message in list(messages)[:10]])


    When I do this I get the error com_error: (-2147467259, 'Unspecified error', None, None) When I try to access the messages.Subject, everything works fine.

    I am operating on the gov (cac enabled) computer and my guess it has something to do with certificates or with permissions. Can anyone confirm this? Thank you!!!

    Continue reading...

Compartilhe esta Página