I am missing something when I try to convert the following single line command into multiple lines. I searched, found, and tried to model this change after Powershell -Command over multiple line
What am I missing? I have tried to make it easy to test. Just change the first two (2) lines to something appropriate for your system.
=== emailtest.bat
@ECHO OFF
SET "RECIPIENT=me@nowhere.org"
SET "SMTPHOST=imr2.nowhere.org"
SET "FN=C:\Windows\win.ini"
@ECHO ON
powershell -Command "& send-mailmessage -to "%RECIPIENT%" -from 'noreply@nowhere.org' -subject 'test file transfer' -SmtpServer '%SMTPHOST%' -BodyAsHTML 'The file is <a href="%FN">here</a> for you.'
powershell -noprofile -Command "&{"^
send-mailmessage -to "%RECIPIENT%" ^
-from 'noreply@nowhere.org' ^
-subject 'test file transfer' ^
-SmtpServer '%SMTPHOST%' ^
-BodyAsHTML 'The file is <a href="%FN%">here</a> for you.'^
"}"
=== The output is
C:>call emailtest.bat
12:17:24.75 C:\Users\me\t
C:>powershell -Command "& send-mailmessage -to "me@nowhere.org" -from 'noreply@nowhere.org' -subject 'test file transfer' -SmtpServer 'imr2.nowhere.org' -BodyAsHTML 'The file is <a href="C:\Windows\win.ini">here</a> for you.'
12:17:27.28 C:\Users\me\t
C:>powershell -noprofile -Command "&{" send-mailmessage -to "me@nowhere.org" -from 'noreply@nowhere.org' -subject 'test file transfer' -SmtpServer 'imr2.nowhere.org' -BodyAsHTML 'The file is href="C:\Windows\win.ini""}" 0</a 1>for
The system cannot find the file specified.