操作outlook通讯薄的问题。我想做一个导出通讯薄的工具,但是操作上不知道怎么实现,只能简单的从Addresslist对象里面提取出Name和Address,而其他详细资料,我不知道怎么取出来了:(ContactItem这个对象里面有好多属性是其他详细资料。可我不知道怎么把关联上取出来呀。。试了两天了,下面是我的代码,只取出了Name和Address,别的不行:(我想要详细一点的,大拿们帮帮忙,看看怎么能搞定这个东西,我在网上查过资料,没有。一点也没有查到:(谢谢了。Private Sub Form_Load()'//Definition Variant And Object--------------------------------------------------------------------------    Dim i As Integer
    Dim myOutlook As Outlook.Application
    Dim myNameSpace As NameSpace
    Dim myAddressList As AddressLists
    'Dim myContactFolder As MAPIFolder
    'Dim myContactItem As ContactItem
    Dim lvItem As ListItem'//Code Part----------------------------------------------------------------------------------------------    Set myOutlook = CreateObject("Outlook.Application")
    Set myNameSpace = myOutlook.GetNamespace("MAPI")
    Set myAddressList = myOutlook.Session.AddressLists
    Set myContactFolder = myNameSpace.GetDefaultFolder(olFolderContacts)    lvListView.ColumnHeaders.Add , "Name", "Name"
    lvListView.ColumnHeaders.Add , "Address", "Address"
    
    For i = 1 To myAddressList.Item(1).AddressEntries.Count
       Set lvItem = lvListView.ListItems.Add(, , myAddressList.Item(1).AddressEntries.Item(i).Name)
       lvItem.SubItems(1) = myAddressList.Item(1).AddressEntries.Item(i).Address
    Next
    
    'MsgBox myContactFolder.Item(1).Name
    'Set myFolder = myNameSpace.GetDefaultFolder(olFolderContacts)
    'MsgBox myNameSpace.GetDefaultFolder(olFolderContacts).Items.Count
    
'//Release Object-----------------------------------------------------------------------------------------    'myContactFolder.Application.Quit
    'Set myContactFolder = Nothing
    myAddressList.Application.Quit
    Set myAddressList = Nothing
    myNameSpace.Application.Quit
    Set myNameSpace = Nothing
    myOutlook.Application.Quit
    Set myOutlook = Nothing
    
End Sub

解决方案 »

  1.   

    myAddressList.Item(1).AddressEntries.Item(i).Name你其实取的是全球通讯薄,我也遇到了同样的问题,想取得全球通讯薄中的FIRSTNAME和LASTNAME,如果是联系人myAddressList.Item(3),是可以取得较详细的信息不知现在解决了吗,给我一点提示吧
      

  2.   

    从 Microsoft Exchange Server 全球通讯簿使用当前用户属性
    在代码中,打开 OLE 邮件传输会话并登录,然后使用下表引用要使用的属性。Set olemSession = Application.CreateObject("MAPI.Session")
    ReturnCode = olemSession.Logon( Application.GetNameSpace("MAPI").CurrentUser, "", False, False, 0 )
    myPage = Item.GetInspector.ModifiedFormPages("Message")
    Set myUser = olemSession.CurrentUser
    Item.UserProperties.Find("Name") = myUser.Name
    Item.UserProperties.Find("Messaging Address") = myUser.Address
    Item.UserProperties.Find("MAPI First Name") = myUser.Fields.item(&h3a06001e)
    通讯簿属性 引用 
    PR_GIVEN_NAME &h3a06001e 
    PR_INITIALS &h3a0a001e 
    PR_SURNAME &h3a11001e 
    PR_7BIT_DISPLAY_NAME &h39ff001e 
    PR_STREET_ADDRESS &h3a29001e 
    PR_LOCALITY &h3a27001e 
    PR_STATE_OR_PROVINCE &h3a28001e 
    PR_POSTAL_CODE &h3a2a001e 
    PR_COUNTRY &h3a26001e 
    PR_TITLE &h3a17001e 
    PR_COMPANY_NAME &h3a16001e 
    PR_DEPARTMENT_NAME &h3a18001e 
    PR_OFFICE_LOCATION &h3a19001e 
    PR_ASSISTANT &h3a30001e 
    PR_BUSINESS_TELEPHONE_NUMBER &h3a08001e 
      

  3.   

    http://www.csdn.net/cnshare/soft/17/17231.shtm
     
      获取本机Outlook  Express和Outlook2000/XP中通讯薄内容的示例源码。