I like to use the Microsoft.Exchange.WebService API:
C# works fine
ExchangeService service = new ExchangeService(userData.Version);
service.Credentials = new NetworkCredential(userData.EmailAddress, userData.Password);
F# gives the error: The type 'NetworkCredential' is not compatible with 'ExchangeCredential'
open System
open Microsoft.Exchange.WebServices.Data
open System.Net
[<EntryPoint>]
let main argv =
let connectToService userData =
let service = new ExchangeService(userData.Version)
do
service.Credentials <- new NetworkCredential(userData.EmailAddress, userData.Password)
service.Url <- userData.AutodicoverUrl
0
I thought it has something to do with implicit conversion that's defined in the C# API. so I tried up (:>) and downcast (:?>). I tried to make it explicite (new NetworkCredential... :ExchangeCredentials) and I've checked the referenced dlls as I used in C# nuget directly and in F# paket. Both tested in VS 2015. In C# it's .Net 4.5.2 and in F#, too if it's the correct way to look it up in the app.config
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
And I guess using WebCredentials is not the correct way. I want to use a SecureString and not a string and if works in C#. So it's more likely that I did something wrong with the F# syntax that I'd like to understand.