$File=“gci \abcd\efgh\ijkl | select -last 1”
$From = “adcb@gmail.com”
$To = “efgh@gmail.com”
$Attachment = $File
$Subject = “Here’s the Email Subject”
$Body = “This is what I want to say”
$SMTPServer = “smtp.gmail.com”
Send-MailMessage -From $From -to $To -Subject $Subject -Body $Body -SmtpServer $SMTPServer -Attachments $Attachment
This is the error I receive:
Send-MailMessage : Illegal characters in path.
At line:1 char:1
- Send-MailMessage -From $From -to $To -Subject $Subject -Body $Body -SmtpServer $ …
-
+ CategoryInfo : NotSpecified: (:) [Send-MailMessage], ArgumentException + FullyQualifiedErrorId : System.ArgumentException,Microsoft.PowerShell.Commands.SendMailMessage
What am I doing wrong here?
Thanks