我有兴趣使用Powershell使用一行代码通过Outlook发送电子邮件。我发现的最接近的是Gmail的这个命令:
Send-MailMessage -smtpServer 'smtp.gmail.com' -port 587 -from 'myself@gmail.com' -to 'myself@gmail.com' -subject 'Test' -body 'Body' –UseSsl
但我想用Outlook做类似的事情。有没有办法把下面的短脚本转换成一行代码?谢谢!
$Outlook = New-Object -ComObject Outlook.Application
$Mail = $Outlook.CreateItem(0)
$Mail.To = "name@domain.com"
$Mail.Subject = "Subject of E-Mail"
$Mail.Body ="Text of Body"
$Mail.Send()
答案 0 :(得分:1)
$Outlook = New-Object -ComObject Outlook.Application;$Mail = $Outlook.CreateItem(0);$Mail.To = "name@domain.com";$Mail.Subject = "Subject of E-Mail";$Mail.Body ="Text of Body";$Mail.Send()