问题
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