【发布时间】:2021-12-01 11:17:43
【问题描述】:
以下代码在 Outlook 中提取 Exchange 用户的多个详细信息。我需要的是提取用户所属的电子邮件组(可能是 name )。我不知道如何访问这个属性。
import win32com.client
import pandas as pd
# Outlook stuff
outApp = win32com.client.gencache.EnsureDispatch("Outlook.Application")
outGAL = outApp.Session.GetGlobalAddressList()
entries = outGAL.AddressEntries
data_set = list()
# Iterates through your contact book and extracts/appends them to a list
for entry in entries:
if entry.Type == "EX":
user = entry.GetExchangeUser()
if user is not None:
if len(user.FirstName) > 0 or len(user.LastName) > 0:
row = list()
row.append(user.FirstName)
row.append(user.LastName)
row.append(user.PrimarySmtpAddress)
row.append(user.Department)
row.append(user.BusinessTelephoneNumber)
row.append(user.MobileTelephoneNumber)
row.append(user.CompanyName)
row.append(user.Name)
row.append(user.JobTitle)
row.append(user.OfficeLocation)
row.append(user.Alias)
row.append(user.City)
row.append(user.Comments)
row.append(user.StateOrProvince)
row.append(user.StreetAddress)
data_set.append(row)
【问题讨论】: