//android.permission.WRITE_CALENDAR public void AddAppointment(DateTime startTime, DateTime endTime, String subject, String location, String details, Boolean isAllDay, AppointmentReminder reminder, AppointmentStatus status) { ContentValues eventValues = new ContentValues(); eventValues.Put(CalendarContract.Events.InterfaceConsts.CalendarId, 1); //_calId); eventValues.Put(CalendarContract.Events.InterfaceConsts.Title, subject); eventValues.Put(CalendarContract.Events.InterfaceConsts.Description, details); eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtstart, startTime.ToUniversalTime().ToString()); // GetDateTimeMS(2011, 12, 15, 10, 0)); eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtend, endTime.ToUniversalTime().ToString()); // GetDateTimeMS(2011, 12, 15, 11, 0)); eventValues.Put(CalendarContract.Events.InterfaceConsts.EventTimezone, "UTC"); eventValues.Put(CalendarContract.Events.InterfaceConsts.EventEndTimezone, "UTC"); eventValues.Put(CalendarContract.Events.InterfaceConsts.Availability, ConvertAppointmentStatus(status)); eventValues.Put(CalendarContract.Events.InterfaceConsts.EventLocation, location); eventValues.Put(CalendarContract.Events.InterfaceConsts.AllDay, (isAllDay) ? "1" : "0"); eventValues.Put(CalendarContract.Events.InterfaceConsts.HasAlarm, "1"); var eventUri = CalendarConnector.Activity.ContentResolver.Insert(CalendarContract.Events.ContentUri, eventValues); long eventID = long.Parse(eventUri.LastPathSegment); ContentValues remindervalues = new ContentValues(); remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.Minutes, ConvertReminder(reminder)); remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.EventId, eventID); remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.Method, (int)RemindersMethod.Alert); var reminderURI = CalendarConnector.Activity.ContentResolver.Insert(CalendarContract.Reminders.ContentUri, remindervalues); }
private int ConvertReminder(AppointmentReminder reminder) { switch (reminder) { case AppointmentReminder.none: return 0; ///todo should this be null? case AppointmentReminder.five: return 5; case AppointmentReminder.fifteen: return 15; case AppointmentReminder.thirty: return 30; } return 0; }
private Microsoft.Phone.Tasks.Reminder ConvertReminder(AppointmentReminder reminder) { switch(reminder) { case AppointmentReminder.none: return Reminder.None; case AppointmentReminder.five: return Reminder.FiveMinutes; case AppointmentReminder.fifteen: return Reminder.FifteenMinutes; case AppointmentReminder.thirty: return Reminder.ThirtyMinutes; } return Reminder.AtStartTime; }
public void AddAppointment(DateTime startTime, DateTime endTime, String subject, String location, String details, Boolean isAllDay, AppointmentReminder reminder, AppointmentStatus status) { SaveAppointmentTask saveAppointmentTask = new SaveAppointmentTask(); saveAppointmentTask.StartTime = startTime; saveAppointmentTask.EndTime = endTime; saveAppointmentTask.Subject = subject; saveAppointmentTask.Location = location; saveAppointmentTask.Details = details; saveAppointmentTask.IsAllDayEvent = isAllDay; saveAppointmentTask.Reminder = ConvertReminder(reminder); saveAppointmentTask.AppointmentStatus = ConvertAppointmentStatus(status); saveAppointmentTask.Show(); }
private EKAlarm ConvertReminder(AppointmentReminder reminder, DateTime startTime) { switch (reminder) { case AppointmentReminder.none: return EKAlarm.FromDate((NSDate)startTime); ///todo should this be null? case AppointmentReminder.five: return EKAlarm.FromDate((NSDate)startTime.AddMinutes(-5)); case AppointmentReminder.fifteen: return EKAlarm.FromDate((NSDate)startTime.AddMinutes(-15)); case AppointmentReminder.thirty: return EKAlarm.FromDate((NSDate)startTime.AddMinutes(-30)); } return EKAlarm.FromDate((NSDate)startTime); }
private EKAlarm ConvertReminder(AppointmentReminder reminder, DateTime startTime) { switch (reminder) { case AppointmentReminder.none: return(EKAlarm.FromDate((NSDate)startTime)); ///todo should this be null? case AppointmentReminder.five: return(EKAlarm.FromDate((NSDate)startTime.AddMinutes(-5))); case AppointmentReminder.fifteen: return(EKAlarm.FromDate((NSDate)startTime.AddMinutes(-15))); case AppointmentReminder.thirty: return(EKAlarm.FromDate((NSDate)startTime.AddMinutes(-30))); } return(EKAlarm.FromDate((NSDate)startTime)); }
private Microsoft.Phone.Tasks.Reminder ConvertReminder(AppointmentReminder reminder) { switch (reminder) { case AppointmentReminder.none: return(Reminder.None); case AppointmentReminder.five: return(Reminder.FiveMinutes); case AppointmentReminder.fifteen: return(Reminder.FifteenMinutes); case AppointmentReminder.thirty: return(Reminder.ThirtyMinutes); } return(Reminder.AtStartTime); }
private int ConvertReminder(AppointmentReminder reminder) { switch (reminder) { case AppointmentReminder.none: return(0); ///todo should this be null? case AppointmentReminder.five: return(5); case AppointmentReminder.fifteen: return(15); case AppointmentReminder.thirty: return(30); } return(0); }
private TimeSpan?ConvertReminder(AppointmentReminder reminder) { switch (reminder) { case AppointmentReminder.none: return(null); case AppointmentReminder.five: return(new TimeSpan(0, 5, 0)); case AppointmentReminder.fifteen: return(new TimeSpan(0, 15, 0)); case AppointmentReminder.thirty: return(new TimeSpan(0, 30, 0)); } return(new TimeSpan(0, 0, 0)); }
public async void AddAppointment(DateTime startTime, DateTime endTime, String subject, String location, String details, Boolean isAllDay, AppointmentReminder reminder, AppointmentStatus status) { var granted = await RequestAccessAsync(); if (granted) { EKEvent newEvent = EKEvent.FromStore(this.EventStore); newEvent.StartDate = (NSDate)DateTime.SpecifyKind(startTime, DateTimeKind.Utc); newEvent.EndDate = (NSDate)DateTime.SpecifyKind(endTime, DateTimeKind.Utc); newEvent.Title = subject; newEvent.Location = location; newEvent.Notes = details; newEvent.AllDay = isAllDay; newEvent.AddAlarm(ConvertReminder(reminder, startTime)); newEvent.Availability = ConvertAppointmentStatus(status); NSError error; this.EventStore.SaveEvent(newEvent, EKSpan.ThisEvent, out error); Console.WriteLine("Event Saved, ID: " + newEvent.CalendarItemIdentifier); } }
static void Main(string[] args) { string location = "Meeting Location: Room 5"; DateTime startDate = new DateTime(1997, 3, 18, 18, 30, 00), endDate = new DateTime(1997, 3, 18, 19, 30, 00); MailAddress organizer = new MailAddress("*****@*****.**", "Organizer"); MailAddressCollection attendees = new MailAddressCollection(); attendees.Add(new MailAddress("*****@*****.**", "First attendee")); Appointment target = new Appointment(location, startDate, endDate, organizer, attendees); //Audio alarm that will sound at a precise time and //repeat 4 more times at 15 minute intervals: AppointmentReminder audioReminder = new AppointmentReminder(); audioReminder.Trigger = new ReminderTrigger(new DateTime(1997, 3, 17, 13, 30, 0, DateTimeKind.Utc)); audioReminder.Repeat = 4; audioReminder.Duration = new ReminderDuration(new TimeSpan(0, 15, 0)); audioReminder.Action = ReminderAction.Audio; ReminderAttachment attach = new ReminderAttachment(new Uri("ftp://host.com/pub/sounds/bell-01.aud")); audioReminder.Attachments.Add(attach); target.Reminders.Add(audioReminder); string strAudioReminder = @" BEGIN:VALARM ACTION:AUDIO REPEAT:4 DURATION:PT15M TRIGGER;VALUE=DATE-TIME:19970317T133000Z ATTACH:ftp://host.com/pub/sounds/bell-01.aud END:VALARM"; //Display alarm that will trigger 30 minutes before the //scheduled start of the event it is //associated with and will repeat 2 more times at 15 minute intervals: AppointmentReminder displayReminder = new AppointmentReminder(); ReminderDuration dur = new ReminderDuration(new TimeSpan(0, -30, 0)); displayReminder.Trigger = new ReminderTrigger(dur, ReminderRelated.Start); displayReminder.Repeat = 2; displayReminder.Duration = new ReminderDuration(new TimeSpan(0, 15, 0)); displayReminder.Action = ReminderAction.Display; displayReminder.Description = "Breakfast meeting with executive team at 8:30 AM EST"; target.Reminders.Add(displayReminder); string strDisplayReminder = @" BEGIN:VALARM ACTION:DISPLAY REPEAT:2 DURATION:PT15M DESCRIPTION:Breakfast meeting with executive team at 8:30 AM EST TRIGGER;RELATED=START:-PT30M END:VALARM"; //Email alarm that will trigger 2 days before the //scheduled due date/time. It does not //repeat. The email has a subject, body and attachment link. AppointmentReminder emailReminder = new AppointmentReminder(); ReminderDuration dur1 = new ReminderDuration(new TimeSpan(-2, 0, 0, 0)); emailReminder.Trigger = new ReminderTrigger(dur1, ReminderRelated.Start); ReminderAttendee attendee = new ReminderAttendee("*****@*****.**"); emailReminder.Attendees.Add(attendee); emailReminder.Action = ReminderAction.Email; emailReminder.Summary = "REMINDER: SEND AGENDA FOR WEEKLY STAFF MEETING"; emailReminder.Description = @"A draft agenda needs to be sent out to the attendees to the weekly managers meeting (MGR-LIST). Attached is a pointer the document template for the agenda file."; ReminderAttachment attach1 = new ReminderAttachment(new Uri("http://host.com/templates/agenda.doc")); emailReminder.Attachments.Add(attach1); target.Reminders.Add(emailReminder); string strEmailReminder = @" BEGIN:VALARM ACTION:EMAIL DESCRIPTION:A draft agenda needs to be sent out to the attendees to the weekly managers meeting (MGR-LIST). Attached is a pointer the document template for the agenda file. SUMMARY:REMINDER: SEND AGENDA FOR WEEKLY STAFF MEETING TRIGGER;RELATED=START:-P2D ATTENDEE:mailto:[email protected] ATTACH:http://host.com/templates/agenda.doc END:VALARM"; //Procedural alarm that will trigger at a precise date/time //and will repeat 23 more times at one hour intervals. The alarm will //invoke a procedure file. AppointmentReminder procReminder = new AppointmentReminder(); procReminder.Trigger = new ReminderTrigger(new DateTime(1998, 1, 1, 5, 0, 0, DateTimeKind.Utc)); procReminder.Repeat = 23; procReminder.Duration = new ReminderDuration(new TimeSpan(1, 0, 0)); procReminder.Action = ReminderAction.Procedure; ReminderAttachment attach2 = new ReminderAttachment(new Uri("ftp://host.com/novo-procs/felizano.exe")); procReminder.Attachments.Add(attach2); target.Reminders.Add(procReminder); string strProcReminder = @" BEGIN:VALARM ACTION:PROCEDURE REPEAT:23 DURATION:PT1H TRIGGER;VALUE=DATE-TIME:19980101T050000Z ATTACH:ftp://host.com/novo-procs/felizano.exe END:VALARM"; target.Save("savedFile.ics"); }
public async void AddAppointment(DateTime startTime, DateTime endTime, String subject, String location, String details, Boolean isAllDay, AppointmentReminder reminder, AppointmentStatus status) { var granted = await RequestAccessAsync(); if (granted) { EKEvent newEvent = EKEvent.FromStore(this.EventStore); newEvent.StartDate = (NSDate)DateTime.SpecifyKind(startTime, DateTimeKind.Utc); newEvent.EndDate = (NSDate)DateTime.SpecifyKind(endTime, DateTimeKind.Utc); newEvent.Title = subject; newEvent.Location = location; newEvent.Notes = details; newEvent.AllDay = isAllDay; newEvent.AddAlarm(ConvertReminder(reminder, startTime)); newEvent.Availability = ConvertAppointmentStatus(status); NSError error; this.EventStore.SaveEvent(newEvent, EKSpan.ThisEvent, out error); Console.WriteLine("Event Saved, ID: " + newEvent.CalendarItemIdentifier); } }
public void AddAppointment(DateTime startTime, DateTime endTime, String subject, String location, String details, Boolean isAllDay, AppointmentReminder reminder, AppointmentStatus status) { var appointment = new Appointment(); appointment.StartTime = startTime; appointment.Duration = endTime.Subtract(startTime); appointment.Subject = subject; appointment.Location = location; appointment.Details = details; appointment.AllDay = isAllDay; appointment.Reminder = ConvertReminder(reminder); appointment.BusyStatus = ConvertAppointmentStatus(status); AppointmentManager.ShowEditNewAppointmentAsync(appointment); }
//android.permission.WRITE_CALENDAR public void AddAppointment(DateTime startTime, DateTime endTime, String subject, String location, String details, Boolean isAllDay, AppointmentReminder reminder, AppointmentStatus status) { ContentValues eventValues = new ContentValues(); eventValues.Put(CalendarContract.Events.InterfaceConsts.CalendarId, 1); //_calId); eventValues.Put(CalendarContract.Events.InterfaceConsts.Title, subject); eventValues.Put(CalendarContract.Events.InterfaceConsts.Description, details); eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtstart, startTime.ToUniversalTime().ToString()); // GetDateTimeMS(2011, 12, 15, 10, 0)); eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtend, endTime.ToUniversalTime().ToString()); // GetDateTimeMS(2011, 12, 15, 11, 0)); eventValues.Put(CalendarContract.Events.InterfaceConsts.EventTimezone, "UTC"); eventValues.Put(CalendarContract.Events.InterfaceConsts.EventEndTimezone, "UTC"); eventValues.Put(CalendarContract.Events.InterfaceConsts.Availability, ConvertAppointmentStatus(status)); eventValues.Put(CalendarContract.Events.InterfaceConsts.EventLocation, location); eventValues.Put(CalendarContract.Events.InterfaceConsts.AllDay, (isAllDay) ? "1" : "0"); eventValues.Put(CalendarContract.Events.InterfaceConsts.HasAlarm, "1"); var eventUri = CalendarConnector.Activity.ContentResolver.Insert(CalendarContract.Events.ContentUri, eventValues); long eventID = long.Parse(eventUri.LastPathSegment); ContentValues remindervalues = new ContentValues(); remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.Minutes, ConvertReminder(reminder)); remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.EventId, eventID); remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.Method, (int)RemindersMethod.Alert); var reminderURI = CalendarConnector.Activity.ContentResolver.Insert(CalendarContract.Reminders.ContentUri, remindervalues); }
public static void Run() { // ExStart:SetReminderByAddingTags // The path to the File directory. string dataDir = RunExamples.GetDataDir_Outlook(); string location = "Meeting Location: Room 5"; DateTime startDate = new DateTime(1997, 3, 18, 18, 30, 00), endDate = new DateTime(1997, 3, 18, 19, 30, 00); MailAddress organizer = new MailAddress("*****@*****.**", "Organizer"); MailAddressCollection attendees = new MailAddressCollection(); attendees.Add(new MailAddress("*****@*****.**", "First attendee")); Appointment target = new Appointment(location, startDate, endDate, organizer, attendees); // Audio alarm that will sound at a precise time and // Repeat 4 more times at 15 minute intervals: AppointmentReminder audioReminder = new AppointmentReminder(); audioReminder.Trigger = new ReminderTrigger(new DateTime(1997, 3, 17, 13, 30, 0, DateTimeKind.Utc)); audioReminder.Repeat = 4; audioReminder.Duration = new ReminderDuration(new TimeSpan(0, 15, 0)); audioReminder.Action = ReminderAction.Audio; ReminderAttachment attach = new ReminderAttachment(new Uri("ftp://Host.com/pub/sounds/bell-01.aud")); audioReminder.Attachments.Add(attach); target.Reminders.Add(audioReminder); // Display alarm that will trigger 30 minutes before the // Scheduled start of the event it is // Associated with and will repeat 2 more times at 15 minute intervals: AppointmentReminder displayReminder = new AppointmentReminder(); ReminderDuration dur = new ReminderDuration(new TimeSpan(0, -30, 0)); displayReminder.Trigger = new ReminderTrigger(dur, ReminderRelated.Start); displayReminder.Repeat = 2; displayReminder.Duration = new ReminderDuration(new TimeSpan(0, 15, 0)); displayReminder.Action = ReminderAction.Display; displayReminder.Description = "Breakfast meeting with executive team at 8:30 AM EST"; target.Reminders.Add(displayReminder); // Email alarm that will trigger 2 days before the // Scheduled due date/time. It does not // Repeat. The email has a subject, body and attachment link. AppointmentReminder emailReminder = new AppointmentReminder(); ReminderDuration dur1 = new ReminderDuration(new TimeSpan(-2, 0, 0, 0)); emailReminder.Trigger = new ReminderTrigger(dur1, ReminderRelated.Start); ReminderAttendee attendee = new ReminderAttendee("*****@*****.**"); emailReminder.Attendees.Add(attendee); emailReminder.Action = ReminderAction.Email; emailReminder.Summary = "REMINDER: SEND AGENDA FOR WEEKLY STAFF MEETING"; emailReminder.Description = @"A draft agenda needs to be sent out to the attendees to the weekly managers meeting (MGR-LIST). Attached is a pointer the document template for the agenda file."; ReminderAttachment attach1 = new ReminderAttachment(new Uri("http://Host.com/templates/agenda.doc")); emailReminder.Attachments.Add(attach1); target.Reminders.Add(emailReminder); // Procedural alarm that will trigger at a precise date/time // And will repeat 23 more times at one hour intervals. The alarm will // Invoke a procedure file. AppointmentReminder procReminder = new AppointmentReminder(); procReminder.Trigger = new ReminderTrigger(new DateTime(1998, 1, 1, 5, 0, 0, DateTimeKind.Utc)); procReminder.Repeat = 23; procReminder.Duration = new ReminderDuration(new TimeSpan(1, 0, 0)); procReminder.Action = ReminderAction.Procedure; ReminderAttachment attach2 = new ReminderAttachment(new Uri("ftp://Host.com/novo-procs/felizano.exe")); procReminder.Attachments.Add(attach2); target.Reminders.Add(procReminder); target.Save(dataDir + "savedFile_out.ics"); //ExEnd:SetReminderByAddingTags }
public static void Run() { // ExStart:SetReminderByAddingTags // The path to the File directory. string dataDir = RunExamples.GetDataDir_Outlook(); string location = "Meeting Location: Room 5"; DateTime startDate = new DateTime(1997, 3, 18, 18, 30, 00), endDate = new DateTime(1997, 3, 18, 19, 30, 00); MailAddress organizer = new MailAddress("*****@*****.**", "Organizer"); MailAddressCollection attendees = new MailAddressCollection(); attendees.Add(new MailAddress("*****@*****.**", "First attendee")); Appointment target = new Appointment(location, startDate, endDate, organizer, attendees); // Audio alarm that will sound at a precise time and // Repeat 4 more times at 15 minute intervals: AppointmentReminder audioReminder = new AppointmentReminder(); audioReminder.Trigger = new ReminderTrigger(new DateTime(1997, 3, 17, 13, 30, 0, DateTimeKind.Utc)); audioReminder.Repeat = 4; audioReminder.Duration = new ReminderDuration(new TimeSpan(0, 15, 0)); audioReminder.Action = ReminderAction.Audio; ReminderAttachment attach = new ReminderAttachment(new Uri("ftp://Host.com/pub/sounds/bell-01.aud")); audioReminder.Attachments.Add(attach); target.Reminders.Add(audioReminder); // Display alarm that will trigger 30 minutes before the // Scheduled start of the event it is // Associated with and will repeat 2 more times at 15 minute intervals: AppointmentReminder displayReminder = new AppointmentReminder(); ReminderDuration dur = new ReminderDuration(new TimeSpan(0, -30, 0)); displayReminder.Trigger = new ReminderTrigger(dur, ReminderRelated.Start); displayReminder.Repeat = 2; displayReminder.Duration = new ReminderDuration(new TimeSpan(0, 15, 0)); displayReminder.Action = ReminderAction.Display; displayReminder.Description = "Breakfast meeting with executive team at 8:30 AM EST"; target.Reminders.Add(displayReminder); // Email alarm that will trigger 2 days before the // Scheduled due date/time. It does not // Repeat. The email has a subject, body and attachment link. AppointmentReminder emailReminder = new AppointmentReminder(); ReminderDuration dur1 = new ReminderDuration(new TimeSpan(-2, 0, 0, 0)); emailReminder.Trigger = new ReminderTrigger(dur1, ReminderRelated.Start); ReminderAttendee attendee = new ReminderAttendee("*****@*****.**"); emailReminder.Attendees.Add(attendee); emailReminder.Action = ReminderAction.Email; emailReminder.Summary = "REMINDER: SEND AGENDA FOR WEEKLY STAFF MEETING"; emailReminder.Description = @"A draft agenda needs to be sent out to the attendees to the weekly managers meeting (MGR-LIST). Attached is a pointer the document template for the agenda file."; ReminderAttachment attach1 = new ReminderAttachment(new Uri("http://Host.com/templates/agenda.doc")); emailReminder.Attachments.Add(attach1); target.Reminders.Add(emailReminder); // Procedural alarm that will trigger at a precise date/time // And will repeat 23 more times at one hour intervals. The alarm will // Invoke a procedure file. AppointmentReminder procReminder = new AppointmentReminder(); procReminder.Trigger = new ReminderTrigger(new DateTime(1998, 1, 1, 5, 0, 0, DateTimeKind.Utc)); procReminder.Repeat = 23; procReminder.Duration = new ReminderDuration(new TimeSpan(1, 0, 0)); procReminder.Action = ReminderAction.Procedure; ReminderAttachment attach2 = new ReminderAttachment(new Uri("ftp://Host.com/novo-procs/felizano.exe")); procReminder.Attachments.Add(attach2); target.Reminders.Add(procReminder); target.Save(dataDir + "savedFile_out.ics"); //ExEnd:SetReminderByAddingTags }
public void AddAppointment(DateTime startTime, DateTime endTime, String subject, String location, String details, Boolean isAllDay, AppointmentReminder reminder, AppointmentStatus status, string sFreq, int iFreqCount, string sEventTimezone) { ContentValues eventValues = new ContentValues(); eventValues.Put(CalendarContract.Events.InterfaceConsts.CalendarId, 1); eventValues.Put(CalendarContract.Events.InterfaceConsts.Title, subject); eventValues.Put(CalendarContract.Events.InterfaceConsts.Description, details); eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtstart, GetDateTimeMS(startTime)); eventValues.Put(CalendarContract.Events.InterfaceConsts.Dtend, GetDateTimeMS(endTime)); // GitHub issue #9 : Event start and end times need timezone support. // https://github.com/xamarin/monodroid-samples/issues/9 eventValues.Put(CalendarContract.Events.InterfaceConsts.EventTimezone, sEventTimezone); eventValues.Put(CalendarContract.Events.InterfaceConsts.EventEndTimezone, sEventTimezone); if (!String.IsNullOrEmpty(sFreq)) { eventValues.Put(CalendarContract.Events.InterfaceConsts.Rrule, String.Format("FREQ={0};COUNT={1}", sFreq, iFreqCount));// "FREQ=DAILY;COUNT=2"); ; } //values.put(CalendarContract.Events.RRULE, "FREQ=DAILY;COUNT=4"); var uri = CalendarConnector.Activity.ContentResolver.Insert(CalendarContract.Events.ContentUri, eventValues); long eventID = long.Parse(uri.LastPathSegment); ContentValues remindervalues = new ContentValues(); remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.Minutes, ConvertReminder(reminder)); remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.EventId, eventID); remindervalues.Put(CalendarContract.Reminders.InterfaceConsts.Method, (int)RemindersMethod.Alert); var reminderURI = CalendarConnector.Activity.ContentResolver.Insert(CalendarContract.Reminders.ContentUri, remindervalues); Console.WriteLine("Uri for new event: {0}", uri); }
static void Main(string[] args) { string location = "Meeting Location: Room 5"; DateTime startDate = new DateTime(1997, 3, 18, 18, 30, 00), endDate = new DateTime(1997, 3, 18, 19, 30, 00); MailAddress organizer = new MailAddress("*****@*****.**", "Organizer"); MailAddressCollection attendees = new MailAddressCollection(); attendees.Add(new MailAddress("*****@*****.**", "First attendee")); Appointment target = new Appointment(location, startDate, endDate, organizer, attendees); //Audio alarm that will sound at a precise time and //repeat 4 more times at 15 minute intervals: AppointmentReminder audioReminder = new AppointmentReminder(); audioReminder.Trigger = new ReminderTrigger(new DateTime(1997, 3, 17, 13, 30, 0, DateTimeKind.Utc)); audioReminder.Repeat = 4; audioReminder.Duration = new ReminderDuration(new TimeSpan(0, 15, 0)); audioReminder.Action = ReminderAction.Audio; ReminderAttachment attach = new ReminderAttachment(new Uri("ftp://host.com/pub/sounds/bell-01.aud")); audioReminder.Attachments.Add(attach); target.Reminders.Add(audioReminder); string strAudioReminder = @" BEGIN:VALARM ACTION:AUDIO REPEAT:4 DURATION:PT15M TRIGGER;VALUE=DATE-TIME:19970317T133000Z ATTACH:ftp://host.com/pub/sounds/bell-01.aud END:VALARM"; //Display alarm that will trigger 30 minutes before the //scheduled start of the event it is //associated with and will repeat 2 more times at 15 minute intervals: AppointmentReminder displayReminder = new AppointmentReminder(); ReminderDuration dur = new ReminderDuration(new TimeSpan(0, -30, 0)); displayReminder.Trigger = new ReminderTrigger(dur, ReminderRelated.Start); displayReminder.Repeat = 2; displayReminder.Duration = new ReminderDuration(new TimeSpan(0, 15, 0)); displayReminder.Action = ReminderAction.Display; displayReminder.Description = "Breakfast meeting with executive team at 8:30 AM EST"; target.Reminders.Add(displayReminder); string strDisplayReminder = @" BEGIN:VALARM ACTION:DISPLAY REPEAT:2 DURATION:PT15M DESCRIPTION:Breakfast meeting with executive team at 8:30 AM EST TRIGGER;RELATED=START:-PT30M END:VALARM"; //Email alarm that will trigger 2 days before the //scheduled due date/time. It does not //repeat. The email has a subject, body and attachment link. AppointmentReminder emailReminder = new AppointmentReminder(); ReminderDuration dur1 = new ReminderDuration(new TimeSpan(-2, 0, 0, 0)); emailReminder.Trigger = new ReminderTrigger(dur1, ReminderRelated.Start); ReminderAttendee attendee = new ReminderAttendee("*****@*****.**"); emailReminder.Attendees.Add(attendee); emailReminder.Action = ReminderAction.Email; emailReminder.Summary = "REMINDER: SEND AGENDA FOR WEEKLY STAFF MEETING"; emailReminder.Description = @"A draft agenda needs to be sent out to the attendees to the weekly managers meeting (MGR-LIST). Attached is a pointer the document template for the agenda file."; ReminderAttachment attach1 = new ReminderAttachment(new Uri("http://host.com/templates/agenda.doc")); emailReminder.Attachments.Add(attach1); target.Reminders.Add(emailReminder); string strEmailReminder = @" BEGIN:VALARM ACTION:EMAIL DESCRIPTION:A draft agenda needs to be sent out to the attendees to the weekly managers meeting (MGR-LIST). Attached is a pointer the document template for the agenda file. SUMMARY:REMINDER: SEND AGENDA FOR WEEKLY STAFF MEETING TRIGGER;RELATED=START:-P2D ATTENDEE:mailto:[email protected] ATTACH:http://host.com/templates/agenda.doc END:VALARM"; //Procedural alarm that will trigger at a precise date/time //and will repeat 23 more times at one hour intervals. The alarm will //invoke a procedure file. AppointmentReminder procReminder = new AppointmentReminder(); procReminder.Trigger = new ReminderTrigger(new DateTime(1998, 1, 1, 5, 0, 0, DateTimeKind.Utc)); procReminder.Repeat = 23; procReminder.Duration = new ReminderDuration(new TimeSpan(1, 0, 0)); procReminder.Action = ReminderAction.Procedure; ReminderAttachment attach2 = new ReminderAttachment(new Uri("ftp://host.com/novo-procs/felizano.exe")); procReminder.Attachments.Add(attach2); target.Reminders.Add(procReminder); string strProcReminder = @" BEGIN:VALARM ACTION:PROCEDURE REPEAT:23 DURATION:PT1H TRIGGER;VALUE=DATE-TIME:19980101T050000Z ATTACH:ftp://host.com/novo-procs/felizano.exe END:VALARM"; target.Save("savedFile.ics"); }
public void AddAppointment(DateTime startTime, DateTime endTime, String subject, String location, String details, Boolean isAllDay, AppointmentReminder reminder, AppointmentStatus status) { SaveAppointmentTask saveAppointmentTask = new SaveAppointmentTask(); saveAppointmentTask.StartTime = startTime; saveAppointmentTask.EndTime = endTime; saveAppointmentTask.Subject = subject; saveAppointmentTask.Location = location; saveAppointmentTask.Details = details; saveAppointmentTask.IsAllDayEvent = isAllDay; saveAppointmentTask.Reminder = ConvertReminder(reminder); saveAppointmentTask.AppointmentStatus = ConvertAppointmentStatus(status); saveAppointmentTask.Show(); }