Send-EWSmail Function

The Send-EWSmail function allows you to send mail without access to (or using) a SMTP server. Function has the ability to send email, with an optional attachement, using Exchange Web Services.

Prerequisites

Microsoft Exchange Web Services Managed API
Mailbox hosted on Exchange or Exchange online (Office 365)

Change Log:

v1 - Initial version.

Examples of using the module (Source code of function is in attachment):  

 

Windows Shell Script
Edit|Remove
Function Send-EWSmail { 
<# 
  .SYNOPSIS 
  Function to send mail using Exchange Web Services 
  .DESCRIPTION 
  This function does not require access to SMTP. It does however need a valid Exchange user and makes use of 
  Microsoft Exchange Web Services Managed API. https://www.microsoft.com/en-us/download/details.aspx?id=42951 
  .EXAMPLE 
  Send-EWSmail -to "user@contoso.com" -Subject "Automated mail" -Body "PowerShell and Exchange rock!" -Credential $Credential 
  .EXAMPLE 
  Send-EWSmail -to "user@contoso.com;user@tailspin.com" -Subject "Automated mail" -Body "The logfiles of today!" -Attachment "c:\temp\logfiles.txt" -Credential $Credential 
  .PARAMETER To 
  Mail receipients. Can be multiple split by either , ; : or space. 
  .PARAMETER Subject 
  The subject of the mail 
   .PARAMETER Body 
  The body of the mail 
   .PARAMETER Attachment 
  Optional the path to an attachment. 
   .PARAMETER Credential 
  Valid user to send mail. eg $Credential = Get-Credential user@contoso.com  
    #>