我不断地从我的Power代码中得到错误,每次我尝试运行它时都会这样说
At C:\Users\thoma\Documents\soubor.ps1:11 char:26
+ $Server = "smtp.gmail.com"
+ ~
The string is missing the terminator: ".
+ CategoryInfo : ParserError: (:) [], ParseException
+ FullyQualifiedErrorId : TerminatorExpectedAtEndOfString
完整代码在这里:
$login = "andrew.spmr01@gmail.com"
$heslo = "MyPassword"
$To = "mek@mailinator.com"
$Copy = "andrew.spmr01@gmail.com"
$Attachment = "test"
$Subject = "Photos of Drogon"
$Body = "<br>Please see attached picture for reference."
$SMTPServer = "smtp.gmail.com"
$heslo = ConvertTo-SecureString "heslo" -AsPlainText –Force
$SMTPPort = "587"
$autentizace = New-Object System.Management.Automation.PSCredential($login, $heslo)
$Server = "smtp.gmail.com"
Send-MailMessage -From $From -to $To -Cc $Copy -Subject $Subject -Body $Body -SmtpServer $Server -Port $SMTPPort -UseSsl -Credential $autentizace -Attachments $Attachment
请给我一个能告诉我这段代码该如何修复的人吗?
发布于 2022-05-09 14:53:51
错误告诉您,PowerShell认为smtp.gmail.com"
末尾的"
是字符串的开头,该字符串后面的命令中没有引号。所以,要么在开头遗漏了一个,要么在行前面有一个额外的;基本上,命令中有一个奇怪的引号。
您发布的代码没有显示问题。你确定这就是全部文件吗?
我注意到您分配了一个名为$SMTPServer
的变量,但是在Send-MailMessage
调用中使用了名为$Server
的变量.错误是指在这里的代码中不存在的对$Server
的赋值。因此,很明显,您发布的代码与您正在运行的代码不同。
https://stackoverflow.com/questions/72173238
复制相似问题