82d7bc375f
- voyage-3-lite returns 512 dims (not 1024) — migrated column + schema - register_vector now called once at connection time, not per-query - Removes per-function register_vector calls that caused type cast conflicts Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
86 lines
2.2 KiB
Python
86 lines
2.2 KiB
Python
import win32com.client
|
|
import pandas as pd
|
|
from pathlib import Path
|
|
|
|
OUT_XLSX = Path(r"C:\Temp\GAL_export.xlsx")
|
|
|
|
def safe_get(obj, attr):
|
|
try:
|
|
return getattr(obj, attr)
|
|
except Exception:
|
|
return None
|
|
|
|
outlook = win32com.client.Dispatch("Outlook.Application")
|
|
ns = outlook.GetNamespace("MAPI")
|
|
|
|
gal = ns.GetGlobalAddressList()
|
|
entries = gal.AddressEntries
|
|
|
|
rows = []
|
|
|
|
print(f"Počet položek v GAL: {entries.Count}")
|
|
|
|
for i in range(1, entries.Count + 1): # Outlook COM je 1-based
|
|
try:
|
|
entry = entries.Item(i)
|
|
|
|
name = safe_get(entry, "Name")
|
|
address = safe_get(entry, "Address")
|
|
entry_type = safe_get(entry, "AddressEntryUserType")
|
|
|
|
smtp = None
|
|
job_title = None
|
|
department = None
|
|
company = None
|
|
office = None
|
|
phone = None
|
|
mobile = None
|
|
|
|
# Exchange user
|
|
try:
|
|
exch_user = entry.GetExchangeUser()
|
|
except Exception:
|
|
exch_user = None
|
|
|
|
if exch_user:
|
|
smtp = safe_get(exch_user, "PrimarySmtpAddress")
|
|
job_title = safe_get(exch_user, "JobTitle")
|
|
department = safe_get(exch_user, "Department")
|
|
company = safe_get(exch_user, "CompanyName")
|
|
office = safe_get(exch_user, "OfficeLocation")
|
|
phone = safe_get(exch_user, "BusinessTelephoneNumber")
|
|
mobile = safe_get(exch_user, "MobileTelephoneNumber")
|
|
|
|
# Distribution list
|
|
try:
|
|
exch_dl = entry.GetExchangeDistributionList()
|
|
except Exception:
|
|
exch_dl = None
|
|
|
|
if exch_dl and not smtp:
|
|
smtp = safe_get(exch_dl, "PrimarySmtpAddress")
|
|
|
|
rows.append({
|
|
"name": name,
|
|
"smtp": smtp,
|
|
"address": address,
|
|
"entry_type": entry_type,
|
|
"job_title": job_title,
|
|
"department": department,
|
|
"company": company,
|
|
"office": office,
|
|
"phone": phone,
|
|
"mobile": mobile,
|
|
})
|
|
|
|
except Exception as e:
|
|
rows.append({
|
|
"name": None,
|
|
"smtp": None,
|
|
"error": str(e),
|
|
})
|
|
|
|
df = pd.DataFrame(rows)
|
|
df.to_excel(OUT_XLSX, index=False)
|
|
|
|
print(f"Hotovo: {OUT_XLSX}") |