我有一个脚本,用于查找文件夹以获取更新,并在出现任何更新时发送电子邮件。如何将电子邮件正文更改或转换为URL或HTML链接而不是文本?Powershell将正文转换为HTML正文
下面的路径和服务器就是例子。
这里是我的脚本:
Param (
[string]$Path = "\\Desktop\Myfolder\status updates",
[string]$SMTPServer = "smtp.myfolder.com",
[string]$From = "[email protected]",
[string]$To = "[email protected]",
[string]$CC = "[email protected]",
[string]$Subject = "New Status Report"
)
$SMTPMessage = @{
To = $To
Cc = $cc
From = $From
Subject = "$Subject"
Smtpserver = $SMTPServer
}
$File = Get-ChildItem $Path | Where { $_.LastWriteTime -ge [datetime]::Now.AddMinutes(-10) }
If ($File)
{ $SMTPBody = "`The following files have recently been added/changed. Please copy and paste the following link to Windows Explorer:`n`n"
$File | ForEach { $SMTPBody += "$($_.FullName)`n" }
Send-MailMessage @SMTPMessage -Body $SMTPBody
你是否期待电子邮件中的网址被点击?在浏览器中打开文件?您将无法真正链接到从大多数电子邮件系统打开资源管理器的本地文件,它只能在浏览器中使用。根据文件类型,这可能是可以接受的。 –