We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Trying To Get Contacts From Exchange

Getting an error when using the following code. Using latest 2.0 dll… What am I missing?

Dim mailboxUri As String = "http://webmail.hartcorp.com/exchange/"

Dim client As ExchangeClient = New ExchangeClient(mailboxUri & hfEmailID.value & "", hfLoginID.value, Server.UrlDecode(hfPwd.value), "domain")

Dim contacts As MapiContact() = client.ListContacts(client.MailboxInfo.ContactsUri)

dgContacts.DataSource = contacts

Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 223:Private Sub dgContacts_NeedDataSource(ByVal [source] As Object, ByVal e As Telerik.WebControls.GridNeedDataSourceEventArgs)

Line 224: Dim client As ExchangeClient = New ExchangeClient(mailboxUri & hfEmailID.value & “”, hfLoginID.value, Server.UrlDecode(hfPwd.value), “domain”)
Line 225: Dim contacts As MapiContact() = client.ListContacts(client.MailboxInfo.ContactsUri)
Line 226: 'dgContacts.DataSource = contacts
Line 227: For Each contact As MapiContact In contacts


Source File: D:\hart11dev\export\mail.aspx Line: 225

Stack Trace:

[NullReferenceException: Object reference not set to an instance of an object.]
Aspose.Network.Outlook.MapiContact…ctor([] ) +327
Aspose.Network.Exchange.ExchangeClient.œˆ(Stream ) +544
Aspose.Network.Exchange.ExchangeClient.ListContacts(String folderUri) +434

Hi,

I am sorry but I was unable to reproduce the exception at my end in the following environment.

  • .NET framework 2.0
  • Aspose.Network for .NET 6.4 (net 2.0 dll)
  • Windows 7 x64
  • Exchange Server 2003
There were few contacts on Exchange Server which were all fetched using the above code.