VBScript Msgbox邮件从Outlook地址簿



我目前有以下脚本:

Set objOutlook = CreateObject("Outlook.Application")
Set objMail = objOutlook.Session.GetSelectNamesDialog
objMail.Display   'To display address book

这将从Outlook打开全局地址列表。现在,当我在联系人上单击或双击(无关紧要)时,我想要一个包含联系人电子邮件地址的消息框。

您可以使用以下代码来获取所选联系人:

If .Display Then 
 'Recipients Resolved 
 'Access Recipients using oDialog.Recipients 
End If 
例如:

Sub ShowContactsInDialog() 
 Dim oDialog As SelectNamesDialog 
 Dim oAL As AddressList 
 Dim oContacts As Folder 
 Set oDialog = Application.Session.GetSelectNamesDialog 
 Set oContacts = _ 
   Application.Session.GetDefaultFolder(olFolderContacts) 
 'Look for the address list that corresponds with the Contacts folder 
 For Each oAL In Application.Session.AddressLists 
  If oAL.GetContactsFolder = oContacts Then 
   Exit For 
  End If 
 Next 
 With oDialog 
  'Initialize the dialog box with the address list representing the Contacts folder 
  .InitialAddressList = oAL 
  .ShowOnlyInitialAddressList = True 
  If .Display Then 
   'Recipients Resolved 
   'Access Recipients using oDialog.Recipients 
  End If 
 End With 
End Sub

最新更新