如何使用Microsoft.Exchange.WebServices API DLL从联系人中读取物理地址 [英] How to Read the Physical Address from contacts using Microsoft.Exchange.WebServices API DLL

查看:152
本文介绍了如何使用Microsoft.Exchange.WebServices API DLL从联系人中读取物理地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用Microsoft.Exchange.WebServices API DLL读取用户outlook中的所有联系人。我已经完成了阅读联系人的代码。但我很惊讶于阅读联系人的实际地址。另外我需要知道如何阅读联系人的电子邮件地址。

请将代码发给我,以便阅读街道,城市,邮政编码等物理地址,

以下是我的下面代码来阅读联系人。

由于ExchangeService = GetExchangeService(),如果服务是Nothing,则退出Sub
Dim view As New ItemView(5000)
view.PropertySet = New PropertySet(BasePropertySet.IdOnly)

Dim findResults As FindItemsResults(Of Item)= service.FindItems(WellKnownFolderName.Contacts,查看)

对于每个项目作为项目在findResults.Items中调整itmContact As Contact = itm
Dim oContact As Contact = Contact.Bind(service,New ItemId(itmContact.Id) .UniqueId))

昏暗的姓氏为字符串= oContact.surname
dim givenn ame as string = oContact.givenname

Dim BusinessPhone as string = oContact.PhoneNumbers(PhoneNumberKey.BusinessPhone)

''物理地址 - ???
''EmailAddress1 - ??

下一个
致谢。

Hi,
  I need to read all the contacts from a users outlook using the  Microsoft.Exchange.WebServices API DLL. I had done the code to read the contacts. But i am struck with reading physical address of the contact. Also I need to know the how to read the email address1 of the contact.


Please send me the code to read the physical address like street, city, postal code, etc.,

Here is my below code to read the contacts.


 Dim service As ExchangeService = GetExchangeService()
        If service Is Nothing Then Exit Sub
        Dim view As New ItemView(5000)
        view.PropertySet = New PropertySet(BasePropertySet.IdOnly)

        Dim findResults As FindItemsResults(Of Item) = service.FindItems(WellKnownFolderName.Contacts, view)

        For Each itm As Item In findResults.Items
            Dim itmContact As Contact = itm
            Dim oContact As Contact = Contact.Bind(service, New ItemId(itmContact.Id.UniqueId))
           
             Dim surname as string = oContact.surname
             dim givenname as string = oContact.givenname

             Dim BusinessPhone as string = oContact.PhoneNumbers(PhoneNumberKey.BusinessPhone)

             ''Physical Address - ???
            
              ''EmailAddress1 - ??


         Next


Thanks.

推荐答案

您读取(和写入)与读取/写入电话号码相同的物理地址,电子邮件地址和IM地址,但物理地址未表示为简单字符串:


You read (and write) physical addresses, e-mail addresses and IM addresses just the same you read/write phone numbers, except that physical addresses are not represented as simple strings:

oContact.EmailAddresses(EmailAddressKey.EmailAddress1) = "someone@contoso.com"

Dim address As PhysicalAddressEntry = New PhysicalAddressEntry()
address.City = "Redmond"
address.CountryOrRegion = "USA"
address.PostalCode = "98052"
' More properties are available

oContact.PhysicalAddresses(PhysicalAddressKey.Home) = address
oContact.ImAddresses(ImAddressKey.ImAddress1) = "imaddress"


这篇关于如何使用Microsoft.Exchange.WebServices API DLL从联系人中读取物理地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆