File size: 1,140 Bytes
34367da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/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()