Sending email message using Exchange Web Service Managed API

Posted by Anuraj on Wednesday, February 4, 2015 Reading time :1 minute

.Net ASP.Net ASP.Net MVC Visual Studio

Microsoft Exchange Web Services (EWS) is an interface by which you can programmatically manage Exchange items such as calendar, contact, and email. Microsoft Exchange Web Services is an Application Programming Interface (API) that provides programmatic access to the information and business logic in Microsoft Exchange Server 2007 or later versions. EWS is now an open source project, you can find it in github

To use EWS API, you need to add reference of Microsoft.Exchange.WebServices.dll, you can do it via nuget.

Install-Package Microsoft.Exchange.WebServices

And here is the code snippet, which will send email.

var service = new ExchangeService(ExchangeVersion.Exchange2013);
service.Credentials =
    new WebCredentials("", "Password");
service.TraceEnabled = true;
service.TraceFlags = TraceFlags.All;
EmailMessage email = new EmailMessage(service);
email.Subject = "HelloWorld";
email.Body = new MessageBody("First email using EWS Managed API");
email.Body.BodyType = BodyType.HTML;

Here is the RedirectionUrlValidationCallback method.

private static bool RedirectionUrlValidationCallback(string redirectionUrl)
    var redirectionUri = new Uri(redirectionUrl);
    var result = redirectionUri.Scheme == "https";
    return result;

Happy Programming :)

What do you think? I would like to hear your thoughts, suggestions, and questions in the comments section below.

Similar Posts

Did you like this article? Share it with your friends

Facebook Twitter Google+ LinkedIn Reddit StumbleUpon

BMC logoBuy me a coffee

Copyright © 2019 - Anuraj P. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer. Hosted with ❤ by GitHub