命令在命令提示符中工作,但不能在批处理文件中工作



我正在尝试使用此命令行客户端定期从批处理脚本发送电子邮件附件

http://caspian.dotconf.net/menu/Software/SendEmail

它的命令非常简单

sendEmail -t abc@gmail.com -u hellp -f abd@nus.edu.sg -m world -s smtp.nus.edu.sg -xu nusstua123456 -xp helloworld! -a C:UsersllDesktopQuotes.docx

奇怪的是,如果我在命令提示符中输入这一行,它工作得很好。我可以接收带附件的电子邮件。

但是,当我把它放入批处理脚本时,比如

:email
sendEmail -t abc@gmail.com -u hellp -f abd@nus.edu.sg -m world -s smtp.nus.edu.sg -xu       nusstua123456 -xp helloworld! -a C:UsersllDesktopQuotes.docx
goto:eof

我在批处理文件中调用这个子程序,输出是

SMTP:AUTH authentication to smtp.nus.edu.sg:25 failed.

我检查。没有打字错误,谁能告诉我有什么不同吗?为什么相同的命令可以在命令行中工作,但在脚本文件中会产生问题?

谢谢

我认为你对这批货审查得太多了。

尝试运行以下命令:

@ECHO OFF
setlocal
echo sendEmail -t abc@gmail.com -u hellp -f abd@nus.edu.sg -m world -s smtp.nus.edu.sg -xu nusstua123456 -xp helloworld! -a C:UsersllDesktopQuotes.docx
endlocal
SETLOCAL enabledelayedexpansion
echo sendEmail -t abc@gmail.com -u hellp -f abd@nus.edu.sg -m world -s smtp.nus.edu.sg -xu nusstua123456 -xp helloworld! -a C:UsersllDesktopQuotes.docx
echo sendEmail -t abc@gmail.com -u hellp -f abd@nus.edu.sg -m world -s smtp.nus.edu.sg -xu  nusstua123456 -xp helloworld^^! -a C:UsersllDesktopQuotes.docx
goto:eof

因为您的密码包含!,如果调用delayeexpand, batch将其解释为变量名。由于变量名没有设置,它被替换为[nothing]和sendtoemail认为您的密码是helloworldUsersllDesktopQuotes.docx -因此错误消息。

最新更新