Save Outlook appointment created from a template to non default calendar

馋奶兔 提交于 2019-12-24 20:01:08

问题


I open a Outlook Meeting template and want to associate the appointment created to a non default calendar in Outlook. The attached code saves to the default calendar.

Sub Whatever()
Dim olApp As Object
Set olApp = GetObject(, "Outlook.Application")
Dim oApt As Outlook.AppointmentItem
Dim myTemplate As Object
Dim ns As Outlook.Namespace
Dim nsOther As Outlook.Recipient

Dim oFolder As Outlook.Folder
Dim template As String

template = "C:\Users\Some User\Meeting.oft"
Set myTemplate = olApp.CreateItemFromTemplate(template)
myTemplate.Recipients.Add ("someuser@contoso.com")
myTemplate.Start = "16/04/2019 10:30"
myTemplate.Display
myTemplate.Send

End Sub

This question is similar but saves a new meeting, not created from a template, to a non default calendar.

This approach stores the html in an Excel cell.


回答1:


Application.CreateItemFromTemplate function takes a second (optional) parameter - MAPIFolder where the appointment must be created.

Your script must initialize the oFolder variable and pass it to CreateItemFromTemplate.



来源:https://stackoverflow.com/questions/55530637/save-outlook-appointment-created-from-a-template-to-non-default-calendar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!