我希望使用powershell发送带有提醒的电子邮件outlook任务,可以吗?任务类似于下图:

powershell内置函数是否能够创建此任务,而不是使用"new-object Net.Mail.MailMessage“创建普通电子邮件?是否有任何示例代码/文档可供参考?
发布于 2018-12-28 12:10:55
在谷歌上快速搜索一下,就会找到这些
发布于 2018-12-28 12:23:16
不,这不是他们所做的。这是一个.Net类,如这里所述。
若要在Outlook中使用PowerShell,必须使用Outlook对象模型(DCOM)。在网络上有很多使用PowerShell的例子。做个搜索就能帮你找到这些。
这里只是一个处理Outlook任务的例子,还有一些其他的参考资料。
Managing an Outlook Mailbox with PowerShell
Getting Things Done – Outlook Task Automation with PowerShell
## Add-OutlookTask.ps1
## Add a task to the Outlook Tasks list
param( $description = $(throw "Please specify a description"), $category, [switch] $force )
## Create our Outlook and housekeeping variables.
## Note: If you don't have the Outlook wrappers, you'll need
## the commented-out constants instead
$olTaskItem = "olTaskItem"
$olFolderTasks = "olFolderTasks"
#$olTaskItem = 3
#$olFolderTasks = 13
$outlook = New-Object -Com Outlook.Application
$task = $outlook.Application.CreateItem($olTaskItem)
$hasError = $false
## Assign the subject
$task.Subject = $description
## If they specify a category, then assign it as well.
if($category)
{
if(-not $force)
{
## Check that it matches one of their already-existing categories, but only
## if they haven't specified the -Force parameter.
$mapi = $outlook.GetNamespace("MAPI")
$items = $mapi.GetDefaultFolder($olFolderTasks).Items
$uniqueCategories = $items | Sort -Unique Categories | % { $_.Categories }
if($uniqueCategories -notcontains $category)
{
$OFS = ", "
$errorMessage = "Category $category does not exist. Valid categories are: $uniqueCategories. " +
"Specify the -Force parameter to override this message in the future."
Write-Error $errorMessage
$hasError = $true
}
}
$task.Categories = $category
}
## Save the item if this didn't cause an error, and clean up.
if(-not $hasError) { $task.Save() }
$outlook = $null 另请参阅此模块:
Powershell and Outlook: Create a New Outlook Task using Powershell OutlookTools Module https://github.com/AmanDhally/OutlookTools
https://stackoverflow.com/questions/53952920
复制相似问题