操作outlook通讯薄的问题

honeyday 2003-03-21 11:37:42
操作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
...全文
139 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
online 2003-06-01
  • 打赏
  • 举报
回复
http://www.csdn.net/cnshare/soft/17/17231.shtm

  获取本机Outlook Express和Outlook2000/XP中通讯薄内容的示例源码。
forever_chang 2003-05-23
  • 打赏
  • 举报
回复
从 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

wang_cel 2003-05-23
  • 打赏
  • 举报
回复
myAddressList.Item(1).AddressEntries.Item(i).Name

你其实取的是全球通讯薄,我也遇到了同样的问题,想取得全球通讯薄中的FIRSTNAME和LASTNAME,如果是联系人myAddressList.Item(3),是可以取得较详细的信息

不知现在解决了吗,给我一点提示吧
wu_yongcai 2003-03-27
  • 打赏
  • 举报
回复
up
honeyday 2003-03-21
  • 打赏
  • 举报
回复
呵呵,谢谢
litsnake1 2003-03-21
  • 打赏
  • 举报
回复
帮你up

2,462

社区成员

发帖
与我相关
我的任务
社区描述
VBA(Visual Basic for Applications)是Visual Basic的一种宏语言,是在其桌面应用程序中执行通用的自动化(OLE)任务的编程语言。
社区管理员
  • VBA
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧