powershell - 使用 Powershell 不在默认日历上创建 Outlook 日历
问题描述
我有一个简单的脚本,它将创建一个 Outlook 日历项目(在线找到),它会很好地创建一个日历项目,但它会将它放在我的默认日历上。我怎样才能让它放在特定的日历上?这就是我所拥有的。
$outlook = new-object -com outlook.application
$CalItem = "1"
$newAppt = $outlook.CreateItem($CalItem)
$newAppt.Body = "Test Body222"
$newAppt.Subject = "Test Subject222"
$newAppt.Start = $OutObject.StartDate
$newAppt.End = $OutObject.ImpEndDate
$newAppt.BusyStatus = 0
$newAppt.Save()
解决方案
我能够做到这一点
# Instantiate a new Outlook object
$ol = new-object -ComObject "Outlook.Application"
# Map to the MAPI namespace
$MyNameSpace = $ol.getnamespace("mapi")
#Default Calendar Folder
$MyDefCal = $MyNameSpace.GetDefaultFolder("olFolderCalendar")
#Folder or "Calendar" I want to add the Item to
$MySharedCal = $MyDefCal.Folders.Item("TestCal")
#Create the Calendar Item
$MyItem = $MySharedCal.Items.Add(1)
$MyItem.Body = "Test"
$MyItem.Subject = "This Is A Test"
$MyItem.Start = "03/01/2019"
$MyItem.AllDayEvent = 1
$MyItem.ReminderSet = 0
$MyItem.BusyStatus = 0
$MyItem.Save()
感谢 Dimitry 的帮助。
推荐阅读
- google-cloud-platform - GCP VPC 对等互连(自动模式)
- plotly - 如何在 react plotly.js 散点图中添加带有 setstate 的 onclick 事件?
- php - 代码覆盖 phpunit 测试问题
- c++ - 在特定位置插入节点
- javascript - 被删除组件的状态覆盖下一个组件
- java - 从文件中使用扫描仪时输入不匹配
- webrtc - 网络音频:如何设置与扬声器不同的目的地?
- sql-server - tSQLt 测试在我的老师工作时不起作用
- python - Tkinter 滞后于“更新”命令
- python - 构建networkx图时的问题