我使用powershell发送邮件命令发送邮件。它很好用。但是我看不到我在中发送的“发送物品”的邮件。如果我手动发送邮件,我可以看到它,但是如果我使用发送邮件命令发送邮件,我无法理解为什么它是不可见的。
谢谢
发布于 2019-03-08 14:45:45
我有一个创建Outlook“草案”的函数。我这样做是为了在点击“发送”之前对电子邮件进行审查。这可能对您不起作用;也许您希望在末尾添加一个send命令。但是,您描述的要做的事情可能需要执行命令的系统上可用的outlook。
它将检查是否首先设置了邮件配置文件,但否则它并不是超级健壮的。
Function Compose-Email {
Param ([String]$recipients, [string]$subject, [string]$body)
$reg="HKCU:\Software\Microsoft\Office\16.0\Outlook\Profiles"
$child=(Get-ChildItem -Path $reg).name
if (!((Get-ChildItem -Path $reg).name)) {
Write-Error "No Mail Profile found! Cannot compose Draft."
}
else {
$olFolderDrafts = 16
$ol = New-Object -comObject Outlook.Application
$ns = $ol.GetNameSpace("MAPI")
# call the save method to save the email in the drafts folder
$mail = $ol.CreateItem(0)
$Mail.Recipients.Add($recipients)
$Mail.Subject = $subject
$Mail.Body = $body
$Mail.save()
$mail.display()
}
}https://stackoverflow.com/questions/55042965
复制相似问题