There are a couple of potential pitfalls I can think of:
1 – Instead of "$Attachment = $File" try "$Attachment = $File.FullName"
2 – Paste it into a text editor like Notepad++, and see if the encoding is dodgy (try ANSI and UTF)
3 – Also in Notepad++, try replacing your double qoutes, I find that some text editors change the double quotes so they aren't compatible with a console.
$File="gci \\abcd\efgh\ijkl | select -last 1"
#it should be
$File=gci \\abcd\efgh\ijkl | select -last 1 -ExpandProperty FullName
when you put everything in double quotes, the whole statement becomes a string.
The topic ‘Powershell email’ is closed to new replies.