A
Alex
Hello All,
Before a question, I describe my System -soft and hardware:
Hardware
Processor: Intel® Xeon™ CPU 2.80GHz
Mamory: 1024MB RAM
DirectX Version: DirectX 9.0b
Software
Operating System: Microsoft Windows 2000 Professional (5.0, Build 2195)
Microsoft® Office Outlook® 2003(11.6401.6408) SP1 (Part of microsoft office
Proffessional Edition 2003)
Here is my code. I took the example from here
http://www.outlookcode.com/d/code/selectnames.htm and modified it a bit for
my needs.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Function GetOneNameViaCDO()
Const cdoE_USER_CANCEL = &H80040113
Dim strAccount
Dim strOffice_Location
Dim strEntryID
Dim strDISPLAY_NAME
Dim strTITLE
Dim strCOMPANY_NAME
Dim strDISPLAY_NAME_PREFIX
Dim strSURNAME
Dim strMIDDLE_NAME
Dim strPR_GIVEN_NAME
Dim strBusiness_Telephone_Number
Dim strMOBILE_TELEPHONE_NUMBER
Dim msg
Dim str
Dim strContact_EmailOriginalDisplayName
Dim strContact_EmailEmailAddress
Dim strContact_EmailAddrType
Dim strPR_EMAIL 'SMTP e-mail address
'VBScript does not recognize constants!
' Define them explicitly or use their value.
Dim cdoPR_Account
Dim cdoPR_Office_Location
Dim cdoPR_EntryID
Dim cdoPR_DISPLAY_NAME
Dim cdoPR_TITLE
Dim cdoPR_COMPANY_NAME
Dim cdoPR_DISPLAY_NAME_PREFIX
Dim cdoPR_SURNAME
Dim cdoPR_MIDDLE_NAME
Dim cdoPR_GIVEN_NAME
Dim cdoPR_Business_Telephone_Number
Dim cdoPR_MOBILE_TELEPHONE_NUMBER
Dim cdoContact_EmailOriginalDisplayName
Dim cdoContact_EmailEmailAddress
Dim CdoContact_EmailAddrType
Dim CdoPR_EMAIL 'SMTP e-mail address
Dim vbCRLF
Const CdoPropSetID3 = "0420060000000000C000000000000046"
cdoPR_Account = &H3A00001E
cdoPR_Office_Location = &H3A19001E
cdoPR_EntryID = &HFFF0102
cdoPR_DISPLAY_NAME = &H3001001F
cdoPR_TITLE = &H3A17001F
cdoPR_COMPANY_NAME = &H3A16001F
cdoPR_DISPLAY_NAME_PREFIX = &H3A45001E
cdoPR_SURNAME = &H3A11001E
cdoPR_MIDDLE_NAME = &H3A44001F
cdoPR_GIVEN_NAME = &H3A06001F
cdoPR_Business_Telephone_Number = &H3A08001F
cdoPR_MOBILE_TELEPHONE_NUMBER = &H3A1C001F
cdoContact_EmailOriginalDisplayName = "{" & CdoPropSetID3 & "}" & "0x8084"
cdoContact_EmailEmailAddress = "{" & CdoPropSetID3 & "}" & "0x8083"
CdoContact_EmailAddrType = "{" & CdoPropSetID3 & "}" & "0x8082"
CdoPR_EMAIL = &H39FE001E
vbCRLF = Chr(13) & Chr(10)
'Dim oSession, oNamespace, oApp
'Set oApp = CreateObject("Outlook.Application")
'Set oNamespace = oApp.GetNamespace("MAPI")
'Set oSession = oApp.CreateObject("MAPI.Session")
'objSession = oSession
' start CDO session
Set objSession = CreateObject("MAPI.Session")
objSession.Logon , , False, False
On Error Resume Next
Set colCDORecips = objSession.AddressBook(, _
"Pick a Person to conatact over VoIP", , , 1, _
"My Contact Partner")
If Err = 0 Then
If colCDORecips.count <> 1 Then
MsgBox "Please choose exactly 1 name.", , _
"Chose One Name"
Else
strAccount =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_Account)
strOffice_Location =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_Office_Location)
strEntryID =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_EntryID)
strDISPLAY_NAME =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_DISPLAY_NAME)
strTITLE = colCDORecips.Item(1).AddressEntry.Fields(cdoPR_TITLE)
strCOMPANY_NAME =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_COMPANY_NAME)
strDISPLAY_NAME_PREFIX =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_DISPLAY_NAME_PREFIX)
strSURNAME =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_SURNAME)
strMIDDLE_NAME =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_MIDDLE_NAME)
strPR_GIVEN_NAME =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_GIVEN_NAME)
strBusiness_Telephone_Number =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_Business_Telephone_Number)
strMOBILE_TELEPHONE_NUMBER =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_MOBILE_TELEPHONE_NUMBER)
strContact_EmailOriginalDisplayName =
colCDORecips.Item(1).AddressEntry.Fields(cdoContact_EmailOriginalDisplayName)
strContact_EmailEmailAddress =
colCDORecips.Item(1).AddressEntry.Fields(cdoContact_EmailEmailAddress)
strContact_EmailAddrType =
colCDORecips.Item(1).AddressEntry.Fields(CdoContact_EmailAddrType)
strPR_EMAIL = colCDORecips.Item(1).AddressEntry.Fields(CdoPR_EMAIL)
Debug.Print "---------------------------"
Debug.Print "strAccount: " & strAccount
Debug.Print "strOffice_Location: " & strOffice_Location
Debug.Print "strEntryID: " & strEntryID
Debug.Print "strDISPLAY_NAME: " & strDISPLAY_NAME
Debug.Print "strTITLE: " & strTITLE
Debug.Print "strCOMPANY_NAME: " & strCOMPANY_NAME
'Debug.Print "strDISPLAY_NAME_PREFIX: " & strDISPLAY_NAME_PREFIX
Debug.Print "strSURNAME: " & strSURNAME
'Debug.Print "strMIDDLE_NAME: " & strMIDDLE_NAME
Debug.Print "strPR_GIVEN_NAME: " & strPR_GIVEN_NAME
Debug.Print "strBusiness_Telephone_Number: " &
strBusiness_Telephone_Number
Debug.Print "strMOBILE_TELEPHONE_NUMBER: " &
strMOBILE_TELEPHONE_NUMBER
'Debug.Print "strContact_EmailOriginalDisplayName: " &
strContact_EmailOriginalDisplayName
'Debug.Print "strContact_EmailEmailAddress: " &
strContact_EmailEmailAddress
'Debug.Print "strContact_EmailAddrType: " &
strContact_EmailAddrType
Debug.Print "strPR_EMAIL: " & strPR_EMAIL
Debug.Print "---------------------------"
If Err = 287 Then
' security block triggered
MsgBox "Outlook cannot return " & _
"a name, because " & _
"you clicked No on the " & _
"e-mail address access " & _
"dialog. You need to try " & _
"again and click Yes " & _
"this time.", , _
"E-mail Address Access"
End If
End If
ElseIf Err = cdoE_USER_CANCEL Then
' user canceled the address book dialog -
' do nothing or provide a message to user
End If
GetOneNameViaCDO = strBusiness_Telephone_Number
' release objects
objSession.Logoff
Set colCDORecips = Nothing
Set objSession = Nothing
End Function
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Ok, now comes my Problem.
I try to access to the GAL (Global Address List). The code above works in
Microsoft® Office Outlook® 2000 without any problems. Now I have installed a
Microsoft® Office Outlook® 2003 and it does not work anymore. I always get an
Exception "Run-time error -142…(ab4401f3)' The operator failed"
I tried to debug the code and I have found out that the exception happens
at the line:
Set objSession = CreateObject("MAPI.Session").
The installed CDO versions are "Microsoft CDO for NTS 1.2 Library" and
"Microsoft CDO for Windows 2000 Library"
Please help me.
Thanks a lot
Alex
PS: Maybe have anybody an idea how I can access a GAL without CDO or
MAPI.Session?
Before a question, I describe my System -soft and hardware:
Hardware
Processor: Intel® Xeon™ CPU 2.80GHz
Mamory: 1024MB RAM
DirectX Version: DirectX 9.0b
Software
Operating System: Microsoft Windows 2000 Professional (5.0, Build 2195)
Microsoft® Office Outlook® 2003(11.6401.6408) SP1 (Part of microsoft office
Proffessional Edition 2003)
Here is my code. I took the example from here
http://www.outlookcode.com/d/code/selectnames.htm and modified it a bit for
my needs.
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Function GetOneNameViaCDO()
Const cdoE_USER_CANCEL = &H80040113
Dim strAccount
Dim strOffice_Location
Dim strEntryID
Dim strDISPLAY_NAME
Dim strTITLE
Dim strCOMPANY_NAME
Dim strDISPLAY_NAME_PREFIX
Dim strSURNAME
Dim strMIDDLE_NAME
Dim strPR_GIVEN_NAME
Dim strBusiness_Telephone_Number
Dim strMOBILE_TELEPHONE_NUMBER
Dim msg
Dim str
Dim strContact_EmailOriginalDisplayName
Dim strContact_EmailEmailAddress
Dim strContact_EmailAddrType
Dim strPR_EMAIL 'SMTP e-mail address
'VBScript does not recognize constants!
' Define them explicitly or use their value.
Dim cdoPR_Account
Dim cdoPR_Office_Location
Dim cdoPR_EntryID
Dim cdoPR_DISPLAY_NAME
Dim cdoPR_TITLE
Dim cdoPR_COMPANY_NAME
Dim cdoPR_DISPLAY_NAME_PREFIX
Dim cdoPR_SURNAME
Dim cdoPR_MIDDLE_NAME
Dim cdoPR_GIVEN_NAME
Dim cdoPR_Business_Telephone_Number
Dim cdoPR_MOBILE_TELEPHONE_NUMBER
Dim cdoContact_EmailOriginalDisplayName
Dim cdoContact_EmailEmailAddress
Dim CdoContact_EmailAddrType
Dim CdoPR_EMAIL 'SMTP e-mail address
Dim vbCRLF
Const CdoPropSetID3 = "0420060000000000C000000000000046"
cdoPR_Account = &H3A00001E
cdoPR_Office_Location = &H3A19001E
cdoPR_EntryID = &HFFF0102
cdoPR_DISPLAY_NAME = &H3001001F
cdoPR_TITLE = &H3A17001F
cdoPR_COMPANY_NAME = &H3A16001F
cdoPR_DISPLAY_NAME_PREFIX = &H3A45001E
cdoPR_SURNAME = &H3A11001E
cdoPR_MIDDLE_NAME = &H3A44001F
cdoPR_GIVEN_NAME = &H3A06001F
cdoPR_Business_Telephone_Number = &H3A08001F
cdoPR_MOBILE_TELEPHONE_NUMBER = &H3A1C001F
cdoContact_EmailOriginalDisplayName = "{" & CdoPropSetID3 & "}" & "0x8084"
cdoContact_EmailEmailAddress = "{" & CdoPropSetID3 & "}" & "0x8083"
CdoContact_EmailAddrType = "{" & CdoPropSetID3 & "}" & "0x8082"
CdoPR_EMAIL = &H39FE001E
vbCRLF = Chr(13) & Chr(10)
'Dim oSession, oNamespace, oApp
'Set oApp = CreateObject("Outlook.Application")
'Set oNamespace = oApp.GetNamespace("MAPI")
'Set oSession = oApp.CreateObject("MAPI.Session")
'objSession = oSession
' start CDO session
Set objSession = CreateObject("MAPI.Session")
objSession.Logon , , False, False
On Error Resume Next
Set colCDORecips = objSession.AddressBook(, _
"Pick a Person to conatact over VoIP", , , 1, _
"My Contact Partner")
If Err = 0 Then
If colCDORecips.count <> 1 Then
MsgBox "Please choose exactly 1 name.", , _
"Chose One Name"
Else
strAccount =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_Account)
strOffice_Location =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_Office_Location)
strEntryID =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_EntryID)
strDISPLAY_NAME =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_DISPLAY_NAME)
strTITLE = colCDORecips.Item(1).AddressEntry.Fields(cdoPR_TITLE)
strCOMPANY_NAME =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_COMPANY_NAME)
strDISPLAY_NAME_PREFIX =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_DISPLAY_NAME_PREFIX)
strSURNAME =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_SURNAME)
strMIDDLE_NAME =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_MIDDLE_NAME)
strPR_GIVEN_NAME =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_GIVEN_NAME)
strBusiness_Telephone_Number =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_Business_Telephone_Number)
strMOBILE_TELEPHONE_NUMBER =
colCDORecips.Item(1).AddressEntry.Fields(cdoPR_MOBILE_TELEPHONE_NUMBER)
strContact_EmailOriginalDisplayName =
colCDORecips.Item(1).AddressEntry.Fields(cdoContact_EmailOriginalDisplayName)
strContact_EmailEmailAddress =
colCDORecips.Item(1).AddressEntry.Fields(cdoContact_EmailEmailAddress)
strContact_EmailAddrType =
colCDORecips.Item(1).AddressEntry.Fields(CdoContact_EmailAddrType)
strPR_EMAIL = colCDORecips.Item(1).AddressEntry.Fields(CdoPR_EMAIL)
Debug.Print "---------------------------"
Debug.Print "strAccount: " & strAccount
Debug.Print "strOffice_Location: " & strOffice_Location
Debug.Print "strEntryID: " & strEntryID
Debug.Print "strDISPLAY_NAME: " & strDISPLAY_NAME
Debug.Print "strTITLE: " & strTITLE
Debug.Print "strCOMPANY_NAME: " & strCOMPANY_NAME
'Debug.Print "strDISPLAY_NAME_PREFIX: " & strDISPLAY_NAME_PREFIX
Debug.Print "strSURNAME: " & strSURNAME
'Debug.Print "strMIDDLE_NAME: " & strMIDDLE_NAME
Debug.Print "strPR_GIVEN_NAME: " & strPR_GIVEN_NAME
Debug.Print "strBusiness_Telephone_Number: " &
strBusiness_Telephone_Number
Debug.Print "strMOBILE_TELEPHONE_NUMBER: " &
strMOBILE_TELEPHONE_NUMBER
'Debug.Print "strContact_EmailOriginalDisplayName: " &
strContact_EmailOriginalDisplayName
'Debug.Print "strContact_EmailEmailAddress: " &
strContact_EmailEmailAddress
'Debug.Print "strContact_EmailAddrType: " &
strContact_EmailAddrType
Debug.Print "strPR_EMAIL: " & strPR_EMAIL
Debug.Print "---------------------------"
If Err = 287 Then
' security block triggered
MsgBox "Outlook cannot return " & _
"a name, because " & _
"you clicked No on the " & _
"e-mail address access " & _
"dialog. You need to try " & _
"again and click Yes " & _
"this time.", , _
"E-mail Address Access"
End If
End If
ElseIf Err = cdoE_USER_CANCEL Then
' user canceled the address book dialog -
' do nothing or provide a message to user
End If
GetOneNameViaCDO = strBusiness_Telephone_Number
' release objects
objSession.Logoff
Set colCDORecips = Nothing
Set objSession = Nothing
End Function
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Ok, now comes my Problem.
I try to access to the GAL (Global Address List). The code above works in
Microsoft® Office Outlook® 2000 without any problems. Now I have installed a
Microsoft® Office Outlook® 2003 and it does not work anymore. I always get an
Exception "Run-time error -142…(ab4401f3)' The operator failed"
I tried to debug the code and I have found out that the exception happens
at the line:
Set objSession = CreateObject("MAPI.Session").
The installed CDO versions are "Microsoft CDO for NTS 1.2 Library" and
"Microsoft CDO for Windows 2000 Library"
Please help me.
Thanks a lot
Alex
PS: Maybe have anybody an idea how I can access a GAL without CDO or
MAPI.Session?