Click here to Skip to main content
15,946,988 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am writing an app to create recurring events in outlook for a specific calendar, which may or may not be the default calendar.

If you are in outlook and right click on a calendar day, you have the option to select "New Recurring Event". I have searched the internet for days and can not find anything that shows how to create a recurring event. Found how to create the appointment, but not the event - I hope I did not read something wrong...lol.

I am kinda new at this, but I want to learn more :)

thanks

What I have tried:

I have tried the following, which creates an appointment, not an event:

Microsoft.Office.Interop.Outlook.Application outlookApplication = GetApplicationObject();
                my_Account = (Account)GetAccountForEmailAddress(outlookApplication, DefaultEmailAddress);
                newAppointment = (AppointmentItem)my_Account.Application.CreateItem(OlItemType.olAppointmentItem);

                recurrencePattern = newAppointment.GetRecurrencePattern();
                recurrencePattern.RecurrenceType = OlRecurrenceType.olRecursYearly;
                recurrencePattern.PatternStartDate = dtStartDate; // new DateTime(2015, 01, 13);
                recurrencePattern.PatternEndDate = dtEndDate; // new DateTime(2015, 03, 20);
                recurrencePattern.StartTime = dtStartTime; 
                recurrencePattern.EndTime = dtEndTime;
                recurrencePattern.MonthOfYear = dtStartDate.Month;
                recurrencePattern.DayOfMonth = dtStartDate.Day;
                recurrencePattern.NoEndDate = true;
                recurrencePattern.Duration = 1440;
                                
                newAppointment.Categories = strCategory;
                newAppointment.Start = dtStartDate;
                newAppointment.End = dtEndDate;
                newAppointment.Location = strLocation;
                newAppointment.Body = strBody;
                newAppointment.AllDayEvent = blAllDayEvent;
                newAppointment.ReminderSet = blReminder;
                newAppointment.ReminderMinutesBeforeStart = intMinutes;
                newAppointment.Subject = strSubject;
                newAppointment.Recipients.Add(strTo);
                newAppointment.MeetingStatus = OlMeetingStatus.olMeeting;
                newAppointment.Save();
Posted
Updated 28-Feb-22 8:28am

An event is just an appointment with "All Day" selected rather than a specific time interval. The AppointmentItem.AllDayEvent property is a boolean.
 
Share this answer
 
thank you - that is correct, example below that worked out:

public static void Test(MAPIFolder myCalendar)
{
AppointmentItem appt = myCalendar.Items.Add(OlItemType.olAppointmentItem) as AppointmentItem;

appt.Subject = "Test Event";
appt.Body = "Testing";
appt.AllDayEvent = true;

RecurrencePattern pattern = appt.GetRecurrencePattern();
pattern.RecurrenceType = OlRecurrenceType.olRecursYearly;

appt.Save();
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900