【问题标题】:Get mailing list, an outlook user is member of. With Python Pywin32获取邮件列表,Outlook 用户是其中的成员。使用 Python Pywin32
【发布时间】: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)

【问题讨论】:

    标签: python outlook pywin32


    【解决方案1】:

    【讨论】:

    • 它返回一个方法。 <bound method _ExchangeUser.GetMemberOfList of <win32com.gen_py.Microsoft Outlook 16.0 Object Library._ExchangeUser instance at 0x2157568189512>>如何获取实际文本。
    • 当然 - 它返回 AddressEntries 对象。您需要遍历列表并为列表的每个成员(AddressEntry 对象)读取其 Name 属性。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-03
    • 2015-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多