Hi, I am trying to develop an automation script that will send an Excel file (.xlsx) to our team. However, during my tests, it seems that the attachments are being converted into text file. As this is my first time trying to use PowerShell to send email, I am not sure whether this is due to our SMTP server setting, or this is the Send-MailMessage cmdlet default.
The test command I have been testing so far:
$mailcred = Get-Credential myusername
$myfile = "C:\Temp\testfile.xlsx"
Send-MailMessage -From "sender@company.com" -to "recipient@company.com" -Subject "Test email from PowerShell cmdlet with attachment" -Body "This is a test email" -Attachments $myfile -Credential $mailcred -SmtpServer 'smtpserver.com' -Port 25 -UseSsl
Are there additional steps I need to do first to be able to send binary file attachments using the Send-MailMessage cmdlet? So far, what I have seen mostly examples in the web are attachments with .txt and .csv files.
Thanks for the advise in advance!