As we saw back in Chapter 2, Exchange Management Shell Common Tasks, we can use the built-in PowerShell cmdlet Send-MailMessage to send email messages. This can be a useful tool when writing scripts that need to send notifications, but the EWS Managed API has several distinct advantages over this approach. In this recipe, we'll take a look at how to send email messages through EWS and why this might be a better option for organizations that have an Exchange infrastructure in place.
Sending email messages with EWS
How to do it...
- First, we'll import the EWS Managed API assembly, create an instance of the ExchangeService class, and set the EWS endpoint using AutoDiscover:
Add-Type -Path
C:\EWS\Microsoft.Exchange...