Using a ready script Get-Office365Endpoints.ps1 connect to https://endpoints.office.com.

Filter that information with IPV4 and SMTP, then send it as txt-file thru Exchange Online using smtp.office365.com

If the endpoint txt-file is found script is stopped. Also includes Aes-encryption for secure password storing.

Only Change EmailAddress, everything else can be used for all environments. You can make a scheduled task of this or run it manually.