Creating Outlook Appointments in a Non-default Folder
If you’ve read my other page at
http://www.dicks-clicks.com/excel/olCalendar.htm#Creating_an_Appointment
then you know how to create an AppointmentItem in the default calendar folder. To create an AppointmentItem in a folder other than the default calendar folder, you can’t use the CreateItem method. Instead you need the Add method of the Items collection object for that folder.
Here’s an example that creates an appointment in a folder called OtherCal.
Sub ApptToOtherCal()
Dim olApp As Outlook.Application
Dim olAppt As Outlook.AppointmentItem
Dim olFldr As Outlook.MAPIFolder
Set olApp = New Outlook.Application
Set olFldr = olApp.GetNamespace(”MAPI”).Folders(”Personal Folders”) _
.Folders(”OtherCal”)
Set olAppt = olFldr.Items.Add
With olAppt
.Start = Now + TimeSerial(1, 0, 0)
.End = Now + TimeSerial(2, 0, 0)
.Subject = “Post to blog”
.Save
End With
Set olApp = Nothing
End Sub
Of course you’ll need to set a reference to the Outlook Object Library for this code to work (it’s early bound).
Calvin:
Thanks…it works[had to fix the quotes]
30 November 2005, 2:17 pmjust what i needed.
George:
You are a life-saver.
Thank you very much.
I was stack to CreateItem method and i didn’t find a method to make .Add to work.
Set olAppt = olFldr.Items.Add is the solution to my probs.
Thanks again……………
22 December 2005, 12:18 pmLeif:
Thanks. It was very helpful. All tutorials should as concise and accurate as this one.
6 February 2006, 12:42 pmKatie:
This was SO helpful!!! Thank you very much!!!!
29 June 2007, 7:38 amDavid Park:
Exactly the information I needed. Thanks…
1 August 2007, 2:22 pm