Quantcast
Channel: Exchange Server Development forum
Viewing all articles
Browse latest Browse all 7132

EWS Api problem connecting Inbox

$
0
0

Hi together

Could someone help me please in this matter.

I am trying to connect to a Inbox using ews api and getting always following error message.

Exception calling "Bind" with "2" argument(s): "The request failed. The underlying connection was closed: An unexpected error occurred on a send."

At C:\Scripts\Entwicklung\SwisEMS\GetInbox2.ps1:18 char:1

+ $Inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderid)

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : ServiceRequestException

My Script connecting to an inbox

Function ConnectExchangeService($ExchangeServer)
{
[Reflection.Assembly]::LoadFile("C:\Program Files (x86)\Microsoft\Exchange\Web Services\2.1\Microsoft.Exchange.WebServices.dll") | Out-Null
$service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP2)
$service.Url = new-object Uri("https://$ExchangeServer/ews/exchange.asmx")
return $service
}
$ExchangeServer = "server.test.com"
$service = ConnectExchangeService $ExchangeServer
$service.Credentials = New-Object System.Net.NetworkCredential('username@domainname','Password')
$MailboxName = "test@test.com"
$service
#Bind to Inbox 
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {return $true}
$folderid= new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$MailboxName)     
$Inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($service,$folderid)    
   $Inbox

Do you have any Suggestion what the Problem is...

Thanks in advance for your help



Viewing all articles
Browse latest Browse all 7132

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>