tags:

views:

14

answers:

1

I'm creating AppointmentItem objects for outlook with the following code:

AppointmentItem apt = (APPointmentItem)OLApp.CreateItem(OlItemType.olAppointmentItem);
// set parameters for 'apt', like body, subject etc.
// ...
apt.Save();

I have the name of a calendar I want to put this event in, but I can't figure out how to specify which folder the newly created event should go in to. New events always seem to appear in the main calendar folder.

+1  A: 

What you need to do is get access to the folder, then call folder.items.add and add you item. It should look something like this:

Microsoft.Office.Interop.Outlook.MAPIFolder customer_folder = GetMyFolder();  //function to get your folder
AppointmentItem apt = (APPointmentItem)OLApp.CreateItem(OlItemType.olAppointmentItem);
// set parameters for 'apt', like body, subject etc.
// ...
apt.Save();
customer_folder.Items.Add(apt);
brendan
When I try this I get an exception: "Could not complete the operation. One or more parameter values are not valid".Any ideas?
Thomi
...Further; MAPIFolder::Items is a read-only property, which is probably why it's complaining about me trying to add something to it.
Thomi