Invalid inbox uri

The following code gives me an invalid inbox uri exception. I’m running this off my local IIS instance, and I’m using the same exchange credentials and server name as what I used to setup Outlook.


string UserID = Session[“UserID”].ToString();
string Password = Session[“Password”].ToString();
string ExchangeServer = Session[“ExchangeServer”].ToString();
string Domain = Session[“Domain”].ToString();
ExchangeClient client = new ExchangeClient(ExchangeServer, UserID, Password, Domain);
ExchangeMessageInfoCollection msgCollection = client.ListMessages(client.MailboxInfo.InboxUri);
gvInbox.DataSource = msgCollection;
gvInbox.DataBind();

Hi,

Thank you for your inquiry.

Please note that the Exchange Server URI is in format as “[https://exchange.domain.com](https://exchange.domain.com/)”. I believe you are not adding the “https://” before the Exchange Server address.

Regards,

I don’t think I had the HTTP part on there, I will try again, and let you know.

I have added the HTTPS:// but now I’m getting an SSL/TLS error. Does this need to be an external name? The only address I have for it is an internal address, but this also needs to be deployable so that we can push our product to our clients and they can use this without having to modify their Exchange server settings.

Hi,


Thank you for your testing.

It would be of great help in rectifying your problem that you provide us some more details regarding your exchange server.

Do you have the exchange server installed locally? If yes, we would like to know it’s configurations. Also, please share the complete exception message/stack trace if possible.

Hi again,

We have further investigated your said issue and we think that you are not specifying the Mailbox to access.

You can specify the Mailbox in two ways,

Either you can specify it directly in ExchangeClient constructor like ExchangeClient(“http[s]://server:port/exchange//”, userName, password, domain)

ExchangeClient client = new ExchangeClient(“https://exchange.test.server/exchange/Test1”, userName, password, domain)

Or if you have defined only exchange server in the constructor, you need to specify the mailbox in GetMailboxInfo method.

ExchangeClient client = new ExchangeClient("https://exchange.test.server", userName, password, domain);
ExchangeMailboxInfo mbInfo = client.GetMailboxInfo("Test1");
ExchangeMessageInfoCollection messages = client.ListMessages(mbInfo.InboxUri);

I switched to using the ExchangeWebServiceClient, and now everything is working.