ASP.NET中是否有任何Outlook联系人控件?

时间:2010-01-19 09:51:27

标签: c# .net asp.net outlook

如何使用ASP.NET访问Microsoft Outlook联系人?有没有可以做到这一点的控件?

3 个答案:

答案 0 :(得分:1)

如果通过控制表示api,那么就有一个 - Exchange Web Services(EWS)。假设您正在处理交换,并设置了EWS。网络服务通常位于:

https://[yourmaildomain.com]/EWS/Exchange.asmx

这是一些快速代码 - 未经过生产测试(也在vb.net中)

Dim esb As New ExchangeServiceBinding()
esb.Credentials = New NetworkCredential("someusername", "somepassword")
esb.Url = "https://[yourmaildomain.com]/EWS/Exchange.asmx"

Dim addressType As New EmailAddressType()
With addressType
 .EmailAddress = "email@domain.com"
 .MailboxType = MailboxTypeType.Mailbox
 .MailboxTypeSpecified = True
End With

' properties
Dim itemProperties As New ItemResponseShapeType()
itemProperties.BaseShape = DefaultShapeNamesType.AllProperties

' Identify which folders to search to find items.
Dim folderIDs(0) As DistinguishedFolderIdType

folderIDs(0) = New DistinguishedFolderIdType()
folderIDs(0).Id = DistinguishedFolderIdNameType.contacts
folderIDs(0).Mailbox = addressType


Dim findItemRequest As New FindItemType()
findItemRequest.Traversal = ItemQueryTraversalType.Shallow
findItemRequest.ItemShape = itemProperties
findItemRequest.ParentFolderIds = folderIDs

' send request
Dim findItemResponse As FindItemResponseType = esb.FindItem(findItemRequest)

Dim rmta As ResponseMessageType() = findItemResponse.ResponseMessages.Items
For Each rmt As ResponseMessageType In rmta
 If rmt.ResponseClass = ResponseClassType.Success Then

  Dim firmt As FindItemResponseMessageType = CType(rmt, FindItemResponseMessageType)
  If firmt IsNot Nothing Then

   Dim root As FindItemParentType = firmt.RootFolder
   Dim obj As Object = root.Item
   If TypeOf obj Is ArrayOfRealItemsType Then
    Dim items As ArrayOfRealItemsType = DirectCast(obj, ArrayOfRealItemsType)
    If items.Items IsNot Nothing Then
     For Each it As ItemType In items.Items
      If TypeOf it Is ContactItemType Then
       Dim cit As ContactItemType = DirectCast(it, ContactItemType)
       Response.Write("<p>")
       Response.Write(cit.Subject)
       Response.Write("<p>")
      End If
     Next
    End If
   End If

  End If

 End If
Next

答案 1 :(得分:0)

您需要创建一个客户端将安装的ActiveX应用程序,以允许您访问它。除非是内部开发项目,否则不要指望人们安装可以访问其电子邮件程序的内容。

答案 2 :(得分:0)