Punit Sharma

Punit Sharma

  • NA
  • 101
  • 56.7k

Error while getting Mails from indox using exchange dll

Sep 16 2015 2:50 AM
Dear All,
 
 
I am using using Microsoft.Exchange.WebServices.Data; for fetching the emails from outlook in  asp.net. But getting the error
 

The remote server returned an error: (403) Forbidden.

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.Net.WebException: The remote server returned an error: (403) Forbidden.

Source Error:
 
Line 42: ItemView view = new ItemView(int.MaxValue); Line 43: // FindItemsResults findResults = service.FindItems(WellKnownFolderName.Inbox, sf, view); Line 44: FindItemsResults findResults = service.FindItems(WellKnownFolderName.Inbox, new ItemView(int.MaxValue)); Line 45: if (findResults != null && findResults.Items != null && findResults.Items.Count > 0) Line 46: {

Source File: e:\CRMEmail\EmailTransfer\Email\Email\UsingEWS.aspx.cs Line: 44

Stack Trace:
 [WebException: The remote server returned an error: (403) Forbidden.] System.Net.HttpWebRequest.GetResponse() +6542104 Microsoft.Exchange.WebServices.Data.EwsHttpWebRequest.Microsoft.Exchange.WebServices.Data.IEwsHttpWebRequest.GetResponse() +47 Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request) +67 [ServiceRequestException: The request failed. The remote server returned an error: (403) Forbidden.] Microsoft.Exchange.WebServices.Data.ServiceRequestBase.GetEwsHttpWebResponse(IEwsHttpWebRequest request) +234 Microsoft.Exchange.WebServices.Data.ServiceRequestBase.ValidateAndEmitRequest(IEwsHttpWebRequest& request) +627 Microsoft.Exchange.WebServices.Data.SimpleServiceRequestBase.InternalExecute() +50 Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute() +55 Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems(IEnumerable`1 parentFolderIds, SearchFilter searchFilter, String queryString, ViewBase view, Grouping groupBy, ServiceErrorHandling errorHandlingMode) +283 Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems(FolderId parentFolderId, SearchFilter searchFilter, ViewBase view) +139 Microsoft.Exchange.WebServices.Data.ExchangeService.FindItems(WellKnownFolderName parentFolderName, ViewBase view) +75 Email.UsingEWS.Page_Load(Object sender, EventArgs e) in e:\CRMEmail\EmailTransfer\Email\Email\UsingEWS.aspx.cs:44 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +51 System.Web.UI.Control.OnLoad(EventArgs e) +92 System.Web.UI.Control.LoadRecursive() +54 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +772
 
 
Please suggest the way ...
 
 
 
Thanks.