I have an application that allows the user to create a recurring e-
mail. My issue is when I open the address book, select a name, and
then continue, I get an error. This used to work, but now I'm on a
different development computer since I first wrote it.
My CDO.DLL version is 6.5.7651.61
The exact line the code breaks on is:
AddRecipsViaCDO = AddRecipsViaCDO &
colCDORecips.Item(iRecipients).AddressEntry.Name & "; "
Error Number: -2147024891
Error Desc: [Collaboration Data Objects - [E_ACCESSDENIED(80070005)]]
My entire code is:
Private Function AddRecipsViaCDO() As String
Dim SafeContact, oContact
Dim iRecipients As Integer
Dim sAddresses As String
Dim oSession As MAPI.Session
Const cdoE_USER_CANCEL = &H80040113
'On Error Resume Next
' start CDO session
Set oSession = CreateObject("MAPI.Session")
oSession.Logon GetDefaultProfileName, , False, False
If Err.Number = -2147221231 Then
oSession.Logon , , True, False
ElseIf Err.Description = "[Collaboration Data Objects -
[MAPI_E_LOGON_FAILED(80040111)]]" Then
oSession.Logon , , True, False
Else
Debug.Print Err.Number & " : " & Err.Description
End If
' Show address book
Set colCDORecips = oSession.AddressBook(, "Choose Recipients", , , 1,
"Recipients")
If Err = 0 Then
For iRecipients = 1 To colCDORecips.Count
'This line invokes the Outlook Security
AddRecipsViaCDO = AddRecipsViaCDO &
colCDORecips.Item(iRecipients).AddressEntry.Name & "; "
Next iRecipients
For iRecipients = 1 To colCDORecips.Count
sAddresses = sAddresses &
colCDORecips.Item(iRecipients).AddressEntry.Address & "; "
Next iRecipients
AddRecipsViaCDO = Left(AddRecipsViaCDO, Len(AddRecipsViaCDO) - 3)
sAddresses = Left(sAddresses, Len(sAddresses) - 3)
ElseIf Err = cdoE_USER_CANCEL Then
' user canceled the address book dialog - do nothing or provide a
message to user
sAddresses = ""
End If
' release objects
oSession.Logoff
Set colCDORecips = Nothing
Set objRecip = Nothing
Set objCDORecip = Nothing
Set colRecips = Nothing
Set oSession = Nothing
gfEmail.Tag = sAddresses
End Function
Archived from group: microsoft>public>office>developer>outlook>vba