views:

133

answers:

5

How can I access Microsoft Outlook contacts using ASP.NET? Are there any controls that can do this?

+3  A: 

See this post answering that very question.

BlueRaja - Danny Pflughoeft
A: 

You would need to create an ActiveX Application that the client would install to allow you access to this. Unless it's an internal development project, don't expect people to install something that gives you access to their email program.

Shawn Steward
+1  A: 

If by control you mean api, there already is one - Exchange Web Services (EWS). Assuming you are dealing with exchange, and have EWS set up. The web services usually sit at:

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

Here is some quick code - not production tested (also in 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 protected]"
 .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
ScottE
Mr. ScottE thank you for response how can i get the assembly of exchange server.
Surya sasidhar
A: 

StesCodes Contact Grabber have services for Gmail, Yahoo, MSN, Hotmail, AOL, AIM, Mail.com, Orkut, Myspace, Facebook, Google wave, Plaxo, Bigstring, Msn Messenger, Opera, kodak, evite, pingg, rediffmail, fastmail and more...

Also have application grabbing services for Outlook CSV, Outlook Express CSV, Thunderbird CSV, Google CSV, Yahoo CSV, Windows live CSV.

Click here to play with the DEMO and SOURCE CODE

  1. Stescodes uses no exe’s
  2. StesCodes uses no user redirection for permission
  3. StesCode source code will work both in shared and dedicated servers
  4. StesCodes provides code update
  5. 100% UI customizable
  6. Uses no OAuth

Source code available in Asp.net, VB.net, WinForms and Webservices for Framework 3.5 and 4.0

navin