使用 PowerShell 设置任务计划程序的电子邮件操作
我正在使用 PowerShell 设置 Windows 任务。我正在使用 New-ScheduledTaskAction 命令来设置操作,但找不到发送电子邮件的选项。
是否可以使用 PowerShell 设置电子邮件操作?
I am setting up Windows Task with PowerShell. I am using New-ScheduledTaskAction
command to setup an action but couldn't find the option to send an email.
Is it possible to set email action with PowerShell?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Powershell 脚本中,您可以使用 Send-MailMessage 命令发送电子邮件,请参阅此处了解语法。
https://ss64.com/ps/send-mailmessage.html
只是依赖显然有一个 SMTP 服务器可以发送,但是您可以构造主题和正文内容作为变量包含在脚本中(例如,有一个包含要包含的内容的字符串变量,然后在调用命令时使用该变量) ,加上包括附件(如果相关)。
Within your Powershell script you can use the Send-MailMessage command to send email, see here for the syntax.
https://ss64.com/ps/send-mailmessage.html
Just relies on having an SMTP server to send through obviously, but you can construct the subject and body content to be included as variables within your script (eg have a string variable with the content you want to include, and then use that variable when calling the command), plus include attachments if relevant.