Read Mail vom Exchange-Server
Verfasst: Donnerstag 3. März 2022, 16:58
Hallo zusammen,
wollte einmal die INBOX von meinem Mail-Account auslesen.
unter Pycharm funktioniert der Code auch einwandfrei.
wenn ich das Programm per py2exe compiliere kriege ich Fehler.
Kann mir jemand helfen?
Hier der Code:
from exchangelib import Credentials, Account
import elementpath
from xml.etree import ElementTree
user = 'xxxxx.yyyyy.de'
pw ='abcedf'
credentials = Credentials(user, pw)
try:
account = Account(user, credentials=credentials, autodiscover=True)
for item in account.inbox.all().order_by('-datetime_received')[:10]:
print(item.subject, item.sender, item.datetime_received)
except:
input ('leider Fehler')
-----
Hier die Fehlermeldung:
--
Traceback (most recent call last):
File "EDIMail2a.py", line 1, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\__init__.py", line 1, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\account.py", line 6, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\autodiscover\__init__.py", line 1, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\autodiscover\cache.py", line 11, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\configuration.py", line 7, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\protocol.py", line 31, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\properties.py", line 11, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\fields.py", line 8, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\ewsdatetime.py", line 12, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\winzone.py", line 7, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\util.py", line 17, in <module>
File "src\lxml\etree.pyx", line 74, in init lxml.etree
ImportError: cannot import name _elementpath
[7048] Failed to execute script 'EDIMail2a' due to unhandled exception!
wollte einmal die INBOX von meinem Mail-Account auslesen.
unter Pycharm funktioniert der Code auch einwandfrei.
wenn ich das Programm per py2exe compiliere kriege ich Fehler.
Kann mir jemand helfen?
Hier der Code:
from exchangelib import Credentials, Account
import elementpath
from xml.etree import ElementTree
user = 'xxxxx.yyyyy.de'
pw ='abcedf'
credentials = Credentials(user, pw)
try:
account = Account(user, credentials=credentials, autodiscover=True)
for item in account.inbox.all().order_by('-datetime_received')[:10]:
print(item.subject, item.sender, item.datetime_received)
except:
input ('leider Fehler')
-----
Hier die Fehlermeldung:
--
Traceback (most recent call last):
File "EDIMail2a.py", line 1, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\__init__.py", line 1, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\account.py", line 6, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\autodiscover\__init__.py", line 1, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\autodiscover\cache.py", line 11, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\configuration.py", line 7, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\protocol.py", line 31, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\properties.py", line 11, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\fields.py", line 8, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\ewsdatetime.py", line 12, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\winzone.py", line 7, in <module>
File "c:\users\rcc ulc\appdata\local\programs\python\python39\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
exec(bytecode, module.__dict__)
File "exchangelib\util.py", line 17, in <module>
File "src\lxml\etree.pyx", line 74, in init lxml.etree
ImportError: cannot import name _elementpath
[7048] Failed to execute script 'EDIMail2a' due to unhandled exception!