找到一份 VB 的,改成Delphi就可以了 Sub GetRecipients_Click Address "CDORecipients","Recipients" End Sub
'********************************************************************* 'Custom Procedure: Address 'Purpose: Display MAPI Address Book, allow user to select 'recipients, and then place recipient names in UD field. 'Aruguments: strUDFieldName, strShortName 'Returns: N/A '********************************************************************* Sub Address(strUDFieldName, strShortName) Dim i Dim strRecip On Error Resume Next strDialogCaption = "Select " & strUDFieldName Set objCDO = Application.CreateObject("MAPI.Session") 'Piggyback on existing Outlook session objCDO.Logon "", "", False, False, 0 If Err Then MsgBox "Could not establish CDO session!", vbCritical End If Set Recips = objCDO.AddressBook(Nothing, _ strDialogCaption, False, True, 1, strShortName, "", "", 0) 'These recipients have been resolved by forceResolution argument above If Not Err Then For i = 1 To Recips.Count strRecip = strRecip & Recips(i).Name & "; " Next If strRecip <> "" Then strRecip = Left(strRecip, Len(strRecip)-2) Userproperties(strUDFieldName) = strRecip End If End If objCDO.Logoff End Sub
Sub GetRecipients_Click
Address "CDORecipients","Recipients"
End Sub
'*********************************************************************
'Custom Procedure: Address
'Purpose: Display MAPI Address Book, allow user to select
'recipients, and then place recipient names in UD field.
'Aruguments: strUDFieldName, strShortName
'Returns: N/A
'*********************************************************************
Sub Address(strUDFieldName, strShortName)
Dim i
Dim strRecip
On Error Resume Next
strDialogCaption = "Select " & strUDFieldName
Set objCDO = Application.CreateObject("MAPI.Session")
'Piggyback on existing Outlook session
objCDO.Logon "", "", False, False, 0
If Err Then
MsgBox "Could not establish CDO session!", vbCritical
End If
Set Recips = objCDO.AddressBook(Nothing, _
strDialogCaption, False, True, 1, strShortName, "", "", 0)
'These recipients have been resolved by forceResolution argument above
If Not Err Then
For i = 1 To Recips.Count
strRecip = strRecip & Recips(i).Name & "; "
Next
If strRecip <> "" Then
strRecip = Left(strRecip, Len(strRecip)-2)
Userproperties(strUDFieldName) = strRecip
End If
End If
objCDO.Logoff
End Sub
第一个的用 cxz7531(追求未知) 的就可以了
第二个就麻烦了
第一个的用 cxz7531(追求未知) 的就可以了
第二个就麻烦了