首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Powershell发送Outlook任务提醒

使用Powershell发送Outlook任务提醒
EN

Stack Overflow用户
提问于 2018-12-28 10:07:00
回答 2查看 1.1K关注 0票数 0

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

powershell内置函数是否能够创建此任务,而不是使用"new-object Net.Mail.MailMessage“创建普通电子邮件?是否有任何示例代码/文档可供参考?

EN

回答 2

Stack Overflow用户

发布于 2018-12-28 12:10:55

在谷歌上快速搜索一下,就会找到这些

  1. https://blogs.technet.microsoft.com/heyscriptingguy/2008/02/21/hey-scripting-guy-how-can-i-set-a-reminder-on-all-my-office-outlook-appointments/
  2. http://www.leeholmes.com/blog/2007/03/01/getting-things-done-outlook-task-automation-with-powershell/
  3. http://www.amandhally.net/2013/08/08/powershell-and-outlook-create-calendar-meetings-using-powershell-function/
票数 0
EN

Stack Overflow用户

发布于 2018-12-28 12:23:16

不,这不是他们所做的。这是一个.Net类,如这里所述。

Mail​Message Class

若要在Outlook中使用PowerShell,必须使用Outlook对象模型(DCOM)。在网络上有很多使用PowerShell的例子。做个搜索就能帮你找到这些。

这里只是一个处理Outlook任务的例子,还有一些其他的参考资料。

Managing an Outlook Mailbox with PowerShell

Getting Things Done – Outlook Task Automation with PowerShell

代码语言:javascript
复制
## 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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53952920

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档