powershell - 如何在 PowerShell 中创建 Outlook 约会/ session ?

标签 powershell outlook appointment meeting-request

如何在 PowerShell 中创建 Outlook 约会/ session ?

最佳答案

以下代码将在 PowerShell 中创建 Outlook 约会。

Function Create-Appointment(){
    [CmdletBinding()]
    param (
        [Parameter(Mandatory=$true)][String]$Subject,
        [Parameter(Mandatory=$true)][DateTime]$MeetingStart,
        [Parameter()][String]$Recipients,
        [Parameter()][String]$Categories,
        [Parameter()][String]$Location,
        [Parameter()][String]$Body=$Subject,
        [Parameter()][int]$ReminderMinutesBeforeStart=15,
        [Parameter()][int]$DurationInMinutes=30
    )

    $ol = New-Object -ComObject Outlook.Application
    $meeting = $ol.CreateItem('olAppointmentItem')

    if($ReminderMinutesBeforeStart -gt 0){
        $meeting.ReminderSet = $true
        $meeting.ReminderMinutesBeforeStart = $ReminderMinutesBeforeStart
    }

    if($PSBoundParameters.ContainsKey('Recipients')){
        foreach($email in $Recipients -split ";"){
            if($email -ne ''){
                $meeting.Recipients.Add($email)
            }
        }
        $meeting.MeetingStatus = [Microsoft.Office.Interop.Outlook.OlMeetingStatus]::olMeeting
    } else {
        $meeting.MeetingStatus = [Microsoft.Office.Interop.Outlook.OlMeetingStatus]::olNonMeeting
    }

    if($PSBoundParameters.ContainsKey('Location')){
        $meeting.Location = $Location
    }

    if($PSBoundParameters.ContainsKey('Categories')){
        $meeting.Categories = $Categories
    } 

    $meeting.Subject = $Subject
    $meeting.Body = $Body
    $meeting.Start = $MeetingStart
    $meeting.Duration = $DurationInMinutes
    $meeting.Save()    
    $meeting.Send()    
}

关于powershell - 如何在 PowerShell 中创建 Outlook 约会/ session ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73778957/

相关文章:

dynamics-crm-2011 - CRM 2011-约会中“主题”字段的“Maximum Length”减少给出错误

java - 应用 SRP 和 OCP

powershell - 在 azure web 角色中设置系统变量 %PATH%

Azure CLI - 自动化帐户替换内容打破新行

vb.net - 将图像添加到 Outlook 中的自定义任务 Pane 标题 - VB.Net

c# - 在 C# 中从 Outlook 添加文件夹到 pst 文件

windows - 有什么方法可以告诉哪些文件在 Windows 系统重新启动时等待删除或重命名?

powershell - Add-AzureAccount -credential 没有像我希望的那样工作

php - 无法使用 PhpMailer 和 Codeigniter 通过 Outlook SMTP 发送电子邮件

c# - 如何从营业时间时段列表中禁用预订的时段