请告知如何获得以下
目标是将所有成员名称打印到文件中。
如何使用VB脚本执行此任务或使用任何其他代码?
示例:
我发现了这个,但我不明白如何在VB代码中设置我的分发列表来打印分发列表成员
例如,如果我有分发列表 MY_HOME 如何在VB代码中插入 MY_HOME 以打印所有成员?
Const olFolderContacts = 10
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
Set colContacts = objNamespace.GetDefaultFolder(olFolderContacts).Items
intCount = colContacts.Count
For i = 1 To intCount
If TypeName(colContacts.Item(1)) = "DistListItem" Then
Set objDistList = colContacts.Item(i)
Wscript.Echo objDistList.DLName
For j = 1 To objDistList.MemberCount
Wscript.Echo objDistList.GetMember(j).Name & " -- " & _
objDistList.GetMember(j).Address
Next
Wscript.Echo
End If
Next
答案 0 :(得分:1)
调用Namespace.CreateRecipient / Recipient.Resolve / Recipient.AddressEntry.Members。
更新:
Set objOutlook = CreateObject("Outlook.Application")
Set objNamespace = objOutlook.GetNamespace("MAPI")
objNamespace.Logon
set objRecip = objNamespace.CreateRecipient("MY_HOME")
if objRecip.Resolve Then
set objMembers = objRecip.AddressEntry.Members
if not (objMembers Is Nothing) Then
for each objMember in objMembers
Wscript.Echo objMember.Name & " : " & objMember.Address
next
end If
End If