使用 PowerShell 设置任务计划程序的电子邮件操作

发布于 2025-01-09 23:34:14 字数 125 浏览 4 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故笙诉离歌 2025-01-16 23:34:14

在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文