Al Grant
Al Grant

Reputation: 2354

Save Outlook appointment created from a template to non default calendar

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 ("[email protected]")
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.

Upvotes: 0

Views: 252

Answers (1)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66245

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.

Upvotes: 1

Related Questions