- PR -

Outlookのアドレス帳情報取得でエラー MAPI

1
投稿者投稿内容
どみの
会議室デビュー日: 2005/12/15
投稿数: 16
投稿日時: 2006-12-08 11:39
おせわになります。

現在、Outlookのアドレス帳の情報を取得するために
いろいろと調査をしております。

調べたところ、MicrosoftのHPに以下のようなコーディング
が参考として記載されておりましたので、試してみたのですが
以下のようなエラーとなります。

注)Microsoft CDO 1.21 Libraryも参照設定しております。

どなたか対応方法をアドバイス頂けないでしょうか

■エラーメッセージ
 実行時エラー’-2147467259(80004005)’
 オートメーションエラーです。
 エラーを特定できません

■エラー箇所
 以下の@の部分



Private Sub Command1_Click()
Const strServer = "MyServer"
Const strMailbox = "MyMailbox"

Dim objSession As MAPI.Session
Dim objAddrEntries As AddressEntries
Dim objAddressEntry As AddressEntry
Dim objFilter As AddressEntryFilter
Dim strProfileInfo As String

strProfileInfo = strServer & vbLf & strMailbox

Set objSession = CreateObject("MAPI.Session") ←@:エラー発生
objSession.Logon , , False, False, , True, strProfileInfo
Set objAddrEntries = objSession.AddressLists _
("Global Address List").AddressEntries
Set objFilter = objAddrEntries.Filter
objFilter.Fields.Add CdoPR_SURNAME, "LastName"
objFilter.Fields.Add CdoPR_GIVEN_NAME, "FirstName"
On Error Resume Next
For Each objAddressEntry In objAddrEntries
Debug.Print objAddressEntry.Name
Debug.Print "E-address: " & objAddressEntry.Address
Debug.Print "Given Name: " & _
objAddressEntry.Fields(CdoPR_GIVEN_NAME).Value
Debug.Print "Initials: " & objAddressEntry.Fields _
(CdoPR_INITIALS).Value
Debug.Print "Surname: " & objAddressEntry.Fields _
(CdoPR_SURNAME).Value
Debug.Print "Display Name: " & objAddressEntry.Fields _
(CdoPR_DISPLAY_NAME).Value
Debug.Print "Alias: " & _
objAddressEntry.Fields(CdoPR_ACCOUNT).Value
Debug.Print "Title: " & _
objAddressEntry.Fields(CdoPR_TITLE).Value
Debug.Print "Company Name: " & objAddressEntry.Fields _
(CdoPR_COMPANY_NAME).Value
Debug.Print "Office Location: " & objAddressEntry.Fields _
(CdoPR_OFFICE_LOCATION).Value
Debug.Print "Office Phone 1: " & objAddressEntry.Fields _
(CdoPR_OFFICE_TELEPHONE_NUMBER).Value
Debug.Print "Office Phone 2: " & objAddressEntry.Fields _
(CdoPR_OFFICE2_TELEPHONE_NUMBER).Value
Debug.Print "Business Fax: " & objAddressEntry.Fields _
(CdoPR_BUSINESS_FAX_NUMBER).Value
Debug.Print "Mobile Phone: " & objAddressEntry.Fields _
(CdoPR_MOBILE_TELEPHONE_NUMBER).Value
Debug.Print "Pager: " & objAddressEntry.Fields _
(CdoPR_PAGER_TELEPHONE_NUMBER).Value
Debug.Print "Assistant: " & objAddressEntry.Fields _
(CdoPR_ASSISTANT).Value
Debug.Print "Assistant Phone: " & objAddressEntry.Fields _
(CdoPR_ASSISTANT_TELEPHONE_NUMBER).Value
Debug.Print "Home Phone 1: " & objAddressEntry.Fields _
(CdoPR_HOME_TELEPHONE_NUMBER).Value
Debug.Print "Home Phone 2: " & objAddressEntry.Fields _
(CdoPR_HOME2_TELEPHONE_NUMBER).Value
Debug.Print "Home Fax: " & objAddressEntry.Fields _
(CdoPR_HOME_FAX_NUMBER).Value
Debug.Print "Home Street: " & objAddressEntry.Fields _
(CdoPR_HOME_ADDRESS_STREET).Value
Debug.Print "Home City: " & objAddressEntry.Fields _
(CdoPR_HOME_ADDRESS_CITY).Value
Debug.Print "Home State: " & objAddressEntry.Fields _
(CdoPR_HOME_ADDRESS_STATE_OR_PROVINCE).Value
Debug.Print "Home Postal Code: " & objAddressEntry.Fields _
(CdoPR_HOME_ADDRESS_POSTAL_CODE).Value
Debug.Print "Home Country: " & objAddressEntry.Fields _
(CdoPR_HOME_ADDRESS_COUNTRY).Value
Debug.Print "Manager Name: " & objAddressEntry.Fields _
(CdoPR_MANAGER_NAME).Value
Debug.Print "Manager Name: " & objAddressEntry.Manager
Next
objSession.Logoff
Set objFilter = Nothing
Set objAddrEntries = Nothing
Set objSession = Nothing

End Sub
1

スキルアップ/キャリアアップ(JOB@IT)