How to send an e-mail through Office 365 using PowerShell

This script allows to send an e-mail through Office 365 using SMTP service available in the platform. The script defines a function that encapsulates all the required parameters to be able to send an e-mail by means of Office 365 SMTP service. These parameters are used to configu

 
 
 
 
 
(0)
1,265 times
Add to favorites
Office 365
7/30/2017
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Error
    2 Posts | Last post Thu 3:01 AM
    • I am getting the following error when try to run this script:
      
      Send-MailMessage : The SMTP server requires a secure connection or the client was not authenticated. The server response was: 5.7.57 SMTP; Client was not 
      authenticated to send anonymous mail during MAIL FROM [MN2PR15CA0057.namprd15.prod.outlook.com]
      At C:\Sources\O365ATP\PS_Send_EMail_Through_O365.ps1:28 char:9
      +         Send-MailMessage -From $sFromEMail -To $To -Cc $cc -Bcc $sBcc ...
      +         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidOperation: (System.Net.Mail.SmtpClient:SmtpClient) [Send-MailMessage], SmtpException
          + FullyQualifiedErrorId : SmtpException,Microsoft.PowerShell.Commands.SendMailMessage
    • Resolved: It requires Exchange Admin rights for FROM user account. 
  • Send Email through Powershell using O365
    2 Posts | Last post May 29, 2019
    • Hi Juan,
      
      Would you happen to have an example of how to fill in the parts needed to complete the script?
      
      Would be much helpful, I realize that some parts of the script give hints as to what should be there, but I am just having trouble getting it to work.  Thanks.
      
      Kendall 
    • Hi Kali,
      Mosts of the parameters you have to fill are just e-mails you want to use when sending an e-mail using PowerShell...it should be quite straightforward to complete those parameters