Hi
I have installed the latest version of GemBox.Email (15.0.1039) and trying to send e-mail using this example.
var exchClient = new ExchangeClient("https://outlook.office365.com/EWS/Exchange.asmx");
exchClient.Authenticate("from@address.no", myAccessToken, ExchangeAuthentication.OAuth2);
var message = new MailMessage(
new MailAddress("from@adddress.no", "From name"),
new MailAddress("to@address.no", "Recipient Name"))
{
Subject = "Send Email in C#",
BodyText = "Hi,\n" +
"This message was created and sent with GemBox.Email.\n" +
"Read more about it on gemboxsoftware"
};
exchClient.SendMessage(message);
The exchClient.SendMessage
code fails with the error:
The remote server returned an error: (500) Internal Server Error.
To verify that my access token is correct and I can send email successfully, I used the same token to successfully send an email using Exchange.WebServices.Managed.Api
:
var ewsClient = new ExchangeService();
ewsClient.Url = new Uri("https://outlook.office365.com/EWS/Exchange.asmx");
ewsClient.Credentials = new OAuthCredentials(myAccessToken);
ewsClient.ImpersonatedUserId = new ImpersonatedUserId(ConnectingIdType.SmtpAddress, "from@address.no");
var message = new EmailMessage(ewsClient)
{
Subject = "This is a test",
Body = new MessageBody(BodyType.HTML, "This is a test body"),
From = new EmailAddress("from@address.no")
};
message.ToRecipients.Add("to@address.no");
message.Send();
Is there a bug in GemBox.Email library for EWS that result in the 500 internal server error?
Thank you
Regards
Arild