I am trying to send email using Exchange Web Service (Microsoft.Exchange.WebServices.NETStandard
) and it is working when I am using Linqpad.
But the same code does not send email when running in Visual Studio. There is no error either.
I am running either app as myself.
Appreciate any idea to troubleshoot this issue.
var service = new ExchangeService(ExchangeVersion.Exchange2016)
{
Url = new Uri("..."),
Credentials = CredentialCache.DefaultNetworkCredentials
};
var address = "...";
var message = new EmailMessage(service)
{
From = address,
Subject = "test",
Body = new MessageBody(BodyType.Text, "test")
};
message.ToRecipients.Add(address);
message.Send();
I changed the Nuget reference in Visual Studio to Microsoft.Exchange.WebService
and that solved the issue.