Use this newer method: https://blog.kimconnect.com/powershell-script-to-send-emails/

### Variables section ###
$fromaddress = "[email protected]"
$toaddress = "[email protected]"
$bccaddress = ""
$CCaddress = ""
$Subject = "EDI Incoming Notification"
$body = "Incoming order has been received and our systems have imported it into the ERP system."
$attachment = "\\FILESERVER01\IT\scripts\EDI-Orders.xls"
$attachment2 = "\\FILESERVER01\IT\scripts\EDI-Summary.xls"
$smtpserver = "kimconnect.mail.protection.outlook.com"

### Sending via SMTP ###
$message = new-object System.Net.Mail.MailMessage
$message.From = $fromaddress
$message.To.Add($toaddress)
$message.CC.Add($CCaddress)
$message.Bcc.Add($bccaddress)
$message.IsBodyHtml = $True
$message.Subject = $Subject
$message.Attachments.Add($attachment)
$message.Attachments.Add($attachment2)
$message.body = $body
$smtp = new-object Net.Mail.SmtpClient($smtpserver)
$smtp.Send($message)