Есть ли в ASP.NET элементы управления контактами Outlook? - PullRequest
0 голосов
/ 19 января 2010

Как я могу получить доступ к контактам Microsoft Outlook, используя ASP.NET? Есть ли какие-либо элементы управления, которые могут сделать это?

Ответы [ 3 ]

1 голос
/ 25 января 2010

Если под контролем вы подразумеваете 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
0 голосов
/ 25 января 2010

Вам потребуется создать приложение ActiveX, которое клиент установит, чтобы предоставить вам доступ к нему. Если это не внутренний проект разработки, не ждите, что люди установят что-то, что даст вам доступ к их почтовой программе.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...