Spaces:
Paused
Paused
| #!/usr/bin/env python3 | |
| """Quick test af Outlook COM forbindelse""" | |
| import sys | |
| print("Starting...") | |
| sys.stdout.flush() | |
| try: | |
| import win32com.client | |
| import pythoncom | |
| print("Imports OK") | |
| sys.stdout.flush() | |
| pythoncom.CoInitialize() | |
| print("CoInitialize OK") | |
| sys.stdout.flush() | |
| outlook = win32com.client.Dispatch("Outlook.Application") | |
| print("Outlook dispatch OK") | |
| sys.stdout.flush() | |
| namespace = outlook.GetNamespace("MAPI") | |
| print("MAPI namespace OK") | |
| sys.stdout.flush() | |
| inbox = namespace.GetDefaultFolder(6) # 6 = Inbox | |
| print(f"Inbox: {inbox.Name}") | |
| print(f"Items: {inbox.Items.Count}") | |
| sys.stdout.flush() | |
| # Get first 3 emails | |
| items = inbox.Items | |
| items.Sort("[ReceivedTime]", True) | |
| for i, mail in enumerate(items): | |
| if i >= 3: | |
| break | |
| try: | |
| print(f" {i+1}. {mail.Subject[:50]}...") | |
| except: | |
| pass | |
| pythoncom.CoUninitialize() | |
| print("\n✅ Outlook COM virker!") | |
| except Exception as e: | |
| print(f"❌ Fejl: {e}") | |
| import traceback | |
| traceback.print_exc() | |