1

私は win32.client を使用し、Python を使用して交換配布リストのメンバーに正常にアクセスできました。ただ、同姓同名のユーザーが2人いるので、名前ではなくメールアドレスでアクセスできるようにしたいです。

以下のループを使用すると、Exchange 配布リストのメンバーを調べて、すべてのメンバーの名前を出力できます。

import win32com.client

outlook_obj = win32com.client.Dispatch("Outlook.Application").GetNamespace("MAPI") 

#This function gets outlook object and retuens all the members of ALL Groups
address_lists = outlook_obj.AddressLists

#Access Exchange Distribution Lists
dist_lists = address_lists['All Distribution Lists']
return(dist_lists)

dl_index = a_numerical_index_greater_than_zero # you can try different numbers until you find the index of your desired distributionList, or loop thorough all the members and find what you are looking for
for m in dist_lists.AddressEntries.Item(dl_index).GetExchangeDistributionList().Members:
    print(str(m))

上記のスクリプトは完全に機能し、配布リストのすべてのメンバーのすべての名前を出力します。ただし、名前が区別されていないため、メンバーの個別の電子メール アドレスを探しています (同じ名前のジャック スミスを持つ 2 人がいる可能性がありますが、jack.smith@xyz.com と jack.smith2@xyz.com はそれでも別物)。

このソースのオブジェクト定義を使用して上記のコードを作成しましたが、メンバーを電子メール アドレスに接続できないようです。

どんな助けにも感謝します!

4

1 に答える 1