Get Contacts from Exchange Server - Fail to connect

Hello,

I can't get your example: http://www.aspose.com/documentation/.net-components/aspose.network-for-.net/get-contacts-information-from-exchange-server.html to work.

At first i get the error "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.".

When i add:

ServicePointManager.ServerCertificateValidationCallback += new System.Net.Security.RemoteCertificateValidationCallback(RemoteCertificateValidationHandler);

// this event handler will be called when SSL certificate is verified
private static bool RemoteCertificateValidationHandler(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return true; //ignore the checks and go ahead
}

The error "The remote server returned an error: (440) Login Timeout." occurs.

I just can't get it to work. Please help.

I need to list all contact that are on our Exchange Server. Perhaps there is another way?

Regards,

Jan Stolk.

Hi Jan,

Thank you for inquiry.

Could you please check whether the URI, username, password and domain is correct?

You may use ExchangeClient class as below, if you have WebDAV enabled. It requires Exchange 2007 or previous versions.

string mailboxURI = “http://ex2003/exchange/administrator”; // WebDAV


string username = “administrator”;


string password = “pwd”;


string domain = “domain.local”;




Console.WriteLine(“Getting contacts information…”);


// credentials for connecting to Exchange Server


NetworkCredential credential = new NetworkCredential(username, password, domain);



And if you have Exchange 2007 or 2010 (no WebDAV), please use ExchangeWebServiceClient class.
string mailboxURI = “https://ex2010/ews/exchange.asmx”; // EWS




string username = “administrator”;


string password = “pwd”;


string domain = “ex2010.local”;




Console.WriteLine(“Getting contacts information…”);


// credentials for connecting to Exchange Server


NetworkCredential credential = new NetworkCredential(username, password, domain);

Hi,

Thank for the reply. The ExchangeWebServiceClient got me logged in.

I can list my contacts, however, these are my personal contacts. I need to list all mailboxes or all e-mail addresses of the mailserver. I have to get a list of all e-mail addresses of my collegues in the same domain/mailserver so our program can send bulk mail to all collegues.

Can this be accomplished?

Thanks.
Jan.

Hi Jan,

Yes, currently it will get those contacts which are added to a specific user’s contact list. For getting email addresses of all users, I have added a new feature request (ID: 29481). We will inform you as soon as this feature becomes available. Sorry for the inconvenience.

The issues you have found earlier (filed as 29481 ) have been fixed in [this update](http://www.aspose.com/community/files/51/.net-components/aspose.network-for-.net/entry325827.aspx).

This message was posted using Notification2Forum from Downloads module by aspose.notifier.

Hi Jan,

Please use the following sample to get all mailboxes and their email addresses.

// initialize the ExchangeClient class and connect
ExchangeWebServiceClient client = new ExchangeWebServiceClient (mailboxURI, credential);

MapiContactCollection contactColl = client.ListMailboxes();
foreach (MapiContact contact in contactColl)
{
Console.WriteLine(contact.NameInfo.DisplayName + ": " + contact.ElectronicAddresses.Email1.EmailAddress);
}

Thanks!

We will check this new feature out.

Kind regards,
Jan.

Hi,

I was wondering if this feature is available if I want to list all mailboxes in Exchange 2003?

Many thanks

Simon

Hi Simon,


Thank you for inquiry.

I am sorry, this feature currently works with Exchange Server 2007 or later only, because we added this method in ExchangeWebServiceClient class.

I have added a new feature request (ID: 32084) to get the contacts from Exchange Server 2003. We will add this feature to ExchangeClient class, if feasible.

The issues you have found earlier (filed as 32084) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.