开发者

Save One Event to Multiple Outlook Calendars

I have several Outlook Calendars. I want to be able to create one event and have it save to each calendar, without having to copy-and-paste it to each calendar.

Any ideas if this is possible / how this can be acc开发者_JAVA百科omplished?


I'm assuming since you posted to SO not SU you need a programatic solution. I don't know a great deal on the subject, but hopefully this will get you started.

Here's how to create a new appointment (from OutlookCode.com)

//First thing you need to do is add a reference to Microsoft Outlook 11.0 Object Library. Then, create new instance of Outlook.Application object: 

Outlook.Application outlookApp = new Outlook.Application (); 

//Next, create an instance of AppointmentItem object and set the properties: 

Outlook.AppointmentItem oAppointment = (Outlook.AppointmentItem) outlookApp.CreateItem (Outlook.OlItemType.olAppointmentItem);

oAppointment.Subject = "This is the subject for my appointment"; 
oAppointment.Body = "This is the body text for my appointment"; 
oAppointment.Location = "Appointment location"; 

// Set the start date
oAppointment.Start = Convert.ToDateTime ("10/10/2004 10:00:00 AM");
// End date 
oAppointment.End = Convert.ToDateTime ("10/10/2004 2:00:00 PM");
// Set the reminder 15 minutes before start
oAppointment.ReminderSet = true; 
oAppointment.ReminderMinutesBeforeStart = 15; 

//Setting the sound file for a reminder: 
set ReminderPlaySound = true 
//set ReminderSoundFile to a filename. 

//Setting the importance: 
//use OlImportance enum to set the importance to low, medium or high

oAppointment.Importance = Outlook.OlImportance.olImportanceHigh; 

/* OlBusyStatus is enum with following values:
olBusy
olFree
olOutOfOffice
olTentative
*/
oAppointment.BusyStatus = Outlook.OlBusyStatus.olBusy; 

//Finally, save the appointment: 

// Save the appointment
oAppointment.Save (); 

// When you call the Save () method, the appointment is saved in Outlook. Another useful method is ForwardAsVcal () which can be used to send the Vcs file via email. 

Outlook.MailItem mailItem = oAppointment.ForwardAsVcal (); 
mailItem.To = "recipients email address"; 
mailItem.Send ();

To get a reference to the calendar, you want something like this:

Outlook.MAPIFolder MyCalendar = Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderCalendar);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜