1

I am using the below Microsoft exchange service url to call the mailbox in my asp.net (4.5) C# application.

https://outlook.office365.com/EWS/Exchange.asmx

The service and and its invocation is working fine while running from Visual Studio 2012.

But while hosting into IIS, I am getting the below error while service method invocation.

The remote server returned an error: (407) Proxy Authentication Required

I am using the below code to invoke service:

   ExchangeService service = new 
   ExchangeService(ExchangeVersion.Exchange2010_SP1);
   service.Credentials = new WebCredentials("praveen.vr@abc.com", "pwd", "dom");
   service.UseDefaultCredentials = true;           
   Microsoft.Exchange.WebServices.Data.Folder rootFolder = 
   Microsoft.Exchange.WebServices.Data.Folder.Bind(service, 
   WellKnownFolderName.MsgFolderRoot);
   rootFolder.Load();
James Z
  • 12,209
  • 10
  • 24
  • 44
Praveen VR
  • 1,554
  • 2
  • 16
  • 34
  • have you check with addingImpersonation service.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "email-address"); ? – Lalji Dhameliya Feb 02 '18 at 07:26
  • I have tried, but now in VS, I m getting the error "The account does not have permission to impersonate the requested user." while service invocation. in IIS,I am getting the older error. – Praveen VR Feb 02 '18 at 07:42
  • Is the working pc and the IIS in the same network? The proxy authentication error usually occurs in a cooperate where outlook is implemented. The port number for email is blocked in the network and requires port forwarding to a proxy server to allow the email port number to get through network. This is to prevent hackers from forwarding email to their accounts. – jdweng Feb 02 '18 at 07:46
  • "Is the working pc and the IIS in the same network?" - YES. same network and same PC. Yes, its a cooperate mail box access. – Praveen VR Feb 02 '18 at 07:59
  • for that you have to give necessary permissions in Office 365 and verify "The account does not have permission to impersonate the requested user." for permission – Lalji Dhameliya Feb 02 '18 at 08:41
  • "you have to give necessary permissions in Office 365" - HOW? – Praveen VR Feb 02 '18 at 10:02
  • have you try https://stackoverflow.com/questions/15204411/the-account-does-not-have-permission-to-impersonate-the-requested-user answer – Lalji Dhameliya Feb 02 '18 at 11:37

0 Answers0