Trabajando con Recurrencias
Trabajando con Recurrencias Diarias
Aspose.Email soporta la creación de recurrencias diarias utilizando MapiCalendarDailyRecurrencePattern. Se pueden usar tres tipos diferentes de fin de recurrencia del calendario Mapi, incluyendo EndAfterNOccurrences, EndAfterDate y NeverEnd. Esta sección demuestra la creación de diferentes patrones de recurrencia diaria.
Recurrencias Diarias: Tipo de Recurrencia EndAfterNOccurrence
En este tipo de recurrencia, se debe establecer el número de recurrencias junto con otra información de la siguiente manera:
- Establecer la fecha de inicio, fin y fecha de vencimiento.
- Crear una MapiTask.
- Establecer el estado de la tarea a NotAssigned.
- Crear el objeto de recurrencia diaria configurando propiedades como PatternType, Period, WeekStartDay, EndType y OccurenceCount.
- Establecer la propiedad MapiTask.Recurrence a este objeto de recurrencia diaria.
- Guardar este mensaje en disco.
El siguiente fragmento de código te muestra cómo crear una tarea con el tipo de fin de recurrencia como EndAfterNOccurrence.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_Outlook(); | |
TimeZone localZone = TimeZone.CurrentTimeZone; | |
TimeSpan timeSpan = localZone.GetUtcOffset(DateTime.Now); | |
DateTime StartDate = new DateTime(2015, 7, 16); | |
StartDate = StartDate.Add(timeSpan); | |
DateTime DueDate = new DateTime(2015, 7, 16); | |
DateTime endByDate = new DateTime(2015, 8, 1); | |
DueDate = DueDate.Add(timeSpan); | |
endByDate = endByDate.Add(timeSpan); | |
MapiTask task = new MapiTask("This is test task", "Sample Body", StartDate, DueDate); | |
task.State = MapiTaskState.NotAssigned; | |
// Set the Daily recurrence | |
var rec = new MapiCalendarDailyRecurrencePattern | |
{ | |
PatternType = MapiCalendarRecurrencePatternType.Day, | |
Period = 1, | |
WeekStartDay = DayOfWeek.Sunday, | |
EndType = MapiCalendarRecurrenceEndType.EndAfterNOccurrences, | |
OccurrenceCount = GetOccurrenceCount(StartDate, endByDate, "FREQ=DAILY"), | |
}; | |
if (rec.OccurrenceCount==0) | |
{ | |
rec.OccurrenceCount = 1; | |
} | |
task.Recurrence = rec; | |
task.Save(dataDir + "Daily_out.msg", TaskSaveFormat.Msg); |
La siguiente función se puede usar para calcular el número de eventos entre las dos fechas:
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
private static uint GetOccurrenceCount(DateTime start, DateTime endBy, string rrule) | |
{ | |
Aspose.iCalendar.RecurrencePattern pattern = new Aspose.iCalendar.RecurrencePattern(string.Format("DTSTART:{0}\r\nRRULE:{1}", start.ToString("yyyyMMdd"),rrule)); | |
Aspose.iCalendar.DateCollection dates = pattern.GenerateOccurrences(start, endBy); | |
return (uint)dates.Count; | |
} |
Estableciendo el valor de cuenta de ocurrencias
El siguiente fragmento de código te muestra cómo establecer el valor de cuenta de ocurrencias.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// Set the Daily recurrence | |
var record = new MapiCalendarDailyRecurrencePattern | |
{ | |
PatternType = MapiCalendarRecurrencePatternType.Day, | |
Period = 1, | |
WeekStartDay = DayOfWeek.Sunday, | |
EndType = MapiCalendarRecurrenceEndType.EndAfterNOccurrences, | |
OccurrenceCount = 5, | |
}; | |
task.Recurrence = record; |
Recurrencias Diarias: Tipo de Recurrencia EndAfterDate
La opción “End By” en la tarea Mapi se logra estableciendo la propiedad OccurrenceCount calculada por la función GetOccurrenceCount(). Esta función toma la fecha de inicio, la fecha de fin y la cadena RRULE.
Recurrencias Diarias: Estableciendo el valor de Every Day
El siguiente fragmento de código te muestra cómo establecer el valor del período a 1 y el valor de INTERVAL a 1 en la cadena RRULE también.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// Set the Daily recurrence | |
var record = new MapiCalendarDailyRecurrencePattern | |
{ | |
PatternType = MapiCalendarRecurrencePatternType.Day, | |
Period = 1, | |
EndType = MapiCalendarRecurrenceEndType.EndAfterDate, | |
OccurrenceCount = GetOccurrenceCount(StartDate, endByDate, "FREQ=DAILY;INTERVAL=1"), | |
EndDate = endByDate | |
}; |
El valor de Every Day se puede establecer en cualquier valor apropiado como se muestra en el siguiente ejemplo:
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// Set the Daily recurrence | |
var record = new MapiCalendarDailyRecurrencePattern | |
{ | |
PatternType = MapiCalendarRecurrencePatternType.Day, | |
Period = 2, | |
EndType = MapiCalendarRecurrenceEndType.EndAfterDate, | |
OccurrenceCount = GetOccurrenceCount(StartDate, endByDate, "FREQ=DAILY;INTERVAL=2"), | |
}; |
Recurrencias Diarias: Tipo de Recurrencia NeverEnd
El tipo de fin se puede establecer utilizando MapiCalendarRecurrenceEndType.NeverEnd. El período o INTERVAL se puede establecer en el valor requerido, digamos 1 en el siguiente ejemplo.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// Set the Daily recurrence | |
var record = new MapiCalendarDailyRecurrencePattern | |
{ | |
PatternType = MapiCalendarRecurrencePatternType.Day, | |
Period = 1, | |
EndType = MapiCalendarRecurrenceEndType.NeverEnd, | |
}; |
Trabajando con Recurrencias Semanales
Aspose.Email proporciona características ricas para la creación de recurrencias semanales utilizando MapiCalendarWeeklyRecurrencePattern. Se pueden usar tres tipos diferentes de fin de recurrencia del calendario Mapi, incluyendo EndAfterNOccurrences, EndAfterDate y NeverEnd. Esta sección demuestra la creación de diferentes patrones de recurrencia semanal.
Recurrencias Semanales: Tipo de Recurrencia EndAfterNOccurrences
En este tipo de recurrencia, se debe establecer el número de recurrencias junto con otra información de la siguiente manera:
- Establecer la fecha de inicio, fin y fecha de vencimiento.
- Crear una MapiTask.
- Establecer el estado de la tarea a NotAssigned.
- Crear el objeto de recurrencia semanal configurando propiedades como PatternType, Period, WeekStartDay, EndType y OccurenceCount.
- Establecer la propiedad MapiTask.Recurrence a este objeto de recurrencia semanal.
- Guardar este mensaje en disco.
El siguiente fragmento de código te muestra cómo crear una tarea con el tipo de fin de recurrencia como EndAfterNOccurrence.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_Outlook(); | |
TimeZone localZone = TimeZone.CurrentTimeZone; | |
TimeSpan ts = localZone.GetUtcOffset(DateTime.Now); | |
DateTime StartDate = new DateTime(2015, 7, 16); | |
StartDate = StartDate.Add(ts); | |
DateTime DueDate = new DateTime(2015, 7, 16); | |
DateTime endByDate = new DateTime(2015, 9, 1); | |
DueDate = DueDate.Add(ts); | |
endByDate = endByDate.Add(ts); | |
MapiTask task = new MapiTask("This is test task", "Sample Body", StartDate, DueDate); | |
task.State = MapiTaskState.NotAssigned; | |
// Set the weekly recurrence | |
var rec = new MapiCalendarWeeklyRecurrencePattern | |
{ | |
EndType = MapiCalendarRecurrenceEndType.EndAfterNOccurrences, | |
PatternType = MapiCalendarRecurrencePatternType.Week, | |
Period = 1, | |
WeekStartDay = DayOfWeek.Sunday, | |
DayOfWeek = MapiCalendarDayOfWeek.Friday, | |
OccurrenceCount = GetOccurrenceCount(StartDate, endByDate, "FREQ=WEEKLY;BYDAY=FR"), | |
}; | |
if (rec.OccurrenceCount == 0) | |
{ | |
rec.OccurrenceCount = 1; | |
} | |
task.Recurrence = rec; | |
task.Save(dataDir + "Weekly_out.msg", TaskSaveFormat.Msg); |
La siguiente función se puede usar para calcular el número de eventos entre las dos fechas:
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
private static uint GetOccurrenceCount(DateTime start, DateTime endBy, string rrule) | |
{ | |
CalendarRecurrence pattern = new CalendarRecurrence(string.Format("DTSTART:{0}\r\nRRULE:{1}", start.ToString("yyyyMMdd"),rrule)); | |
DateCollection dates = pattern.GenerateOccurrences(start, endBy); | |
return (uint)dates.Count; | |
} |
Seleccionando múltiples días en una semana
El siguiente fragmento de código te muestra cómo seleccionar múltiples días en una semana.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// Set the weekly recurrence | |
var rec = new MapiCalendarWeeklyRecurrencePattern | |
{ | |
EndType = MapiCalendarRecurrenceEndType.EndAfterNOccurrences, | |
PatternType = MapiCalendarRecurrencePatternType.Week, | |
Period = 1, | |
WeekStartDay = DayOfWeek.Sunday, | |
DayOfWeek = MapiCalendarDayOfWeek.Friday | MapiCalendarDayOfWeek.Monday, | |
OccurrenceCount = GetOccurrenceCount(StartDate, endByDate, "FREQ=WEEKLY;BYDAY=FR,MO"), | |
}; |
Seleccionando múltiples días en una semana y estableciendo intervalos
El siguiente fragmento de código te muestra cómo seleccionar múltiples días en una semana y establecer intervalos.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// Set the weekly recurrence | |
var rec = new MapiCalendarWeeklyRecurrencePattern | |
{ | |
EndType = MapiCalendarRecurrenceEndType.EndAfterNOccurrences, | |
PatternType = MapiCalendarRecurrencePatternType.Week, | |
Period = 2, | |
WeekStartDay = DayOfWeek.Sunday, | |
DayOfWeek = MapiCalendarDayOfWeek.Friday | MapiCalendarDayOfWeek.Monday, | |
OccurrenceCount = GetOccurrenceCount(StartDate, endByDate, "FREQ=WEEKLY;BYDAY=FR,MO;INTERVAL=2"), | |
}; |
Recurrencias Semanales: Tipo de Recurrencia EndAfterDate
La opción “End By” en la tarea Mapi se logra estableciendo la propiedad OccurrenceCount calculada por la función GetOccurrenceCount(). Esta función toma la fecha de inicio, la fecha de fin y la cadena RRULE.
Recurrencias Semanales: Estableciendo el valor de Every Day
El siguiente fragmento de código te muestra cómo establecer el valor del período a 1 y el valor de INTERVAL a 1 en la cadena RRULE también.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// Set the weekly recurrence | |
var rec = new MapiCalendarWeeklyRecurrencePattern | |
{ | |
EndType = MapiCalendarRecurrenceEndType.EndAfterDate, | |
PatternType = MapiCalendarRecurrencePatternType.Week, | |
Period = 1, | |
WeekStartDay = DayOfWeek.Sunday, | |
DayOfWeek = MapiCalendarDayOfWeek.Friday, | |
EndDate = endByDate, | |
OccurrenceCount = GetOccurrenceCount(StartDate, endByDate, "FREQ=WEEKLY;BYDAY=FR;INTERVAL=1"), | |
}; |
El valor de Every Day se puede establecer en cualquier valor apropiado y se pueden seleccionar múltiples días como se muestra en el siguiente ejemplo:
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
var record = new MapiCalendarWeeklyRecurrencePattern | |
{ | |
EndType = MapiCalendarRecurrenceEndType.EndAfterDate, | |
PatternType = MapiCalendarRecurrencePatternType.Week, | |
Period = 2, | |
WeekStartDay = DayOfWeek.Sunday, | |
EndDate = endByDate, | |
DayOfWeek = MapiCalendarDayOfWeek.Friday | MapiCalendarDayOfWeek.Monday, | |
OccurrenceCount = GetOccurrenceCount(StartDate, endByDate, "FREQ=WEEKLY;BYDAY=FR,MO;INTERVAL=2"), | |
}; |
Recurrencias Semanales: Tipo de Recurrencia NeverEnd
El tipo de fin se puede establecer utilizando MapiCalendarRecurrenceEndType.NeverEnd. El período o INTERVAL se puede establecer en el valor requerido, digamos 1 en el siguiente ejemplo.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// Set the weekly recurrence | |
var recurrence = new MapiCalendarWeeklyRecurrencePattern | |
{ | |
EndType = MapiCalendarRecurrenceEndType.NeverEnd, | |
PatternType = MapiCalendarRecurrencePatternType.Week, | |
Period = 1, | |
WeekStartDay = DayOfWeek.Sunday, | |
DayOfWeek = MapiCalendarDayOfWeek.Friday, | |
OccurrenceCount = GetOccurrenceCount(StartDate, endByDate, "FREQ=WEEKLY;BYDAY=FR"), | |
}; |
Trabajando con Recurrencias Mensuales
Aspose.Email soporta la creación de recurrencias mensuales utilizando MapiCalendarMonthlyRecurrencePattern. Se pueden usar tres tipos diferentes de fin de recurrencia del calendario Mapi, incluyendo EndAfterNOccurrences, EndAfterDate y NeverEnd. Esta sección demuestra la creación de diferentes patrones de recurrencia mensual.
Recurrencias Mensuales: Tipo de Recurrencia EndAfterNOccurrences
En este tipo de recurrencia, se debe establecer el número de recurrencias junto con otra información de la siguiente manera:
- Establecer la fecha de inicio, fin y fecha de vencimiento.
- Crear una MapiTask.
- Establecer el estado de la tarea a NotAssigned.
- Crear el objeto de recurrencia mensual configurando propiedades como PatternType, Period, WeekStartDay, EndType y OccurenceCount.
- Establecer la propiedad MapiTask.Recurrence a este objeto de recurrencia mensual.
- Guardar este mensaje en disco.
El siguiente fragmento de código te muestra cómo crear una tarea con el tipo de fin de recurrencia como EndAfterNOccurrence.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_Outlook(); | |
TimeZone localZone = TimeZone.CurrentTimeZone; | |
TimeSpan ts = localZone.GetUtcOffset(DateTime.Now); | |
DateTime StartDate = new DateTime(2015, 7, 16); | |
StartDate = StartDate.Add(ts); | |
DateTime DueDate = new DateTime(2015, 7, 16); | |
DateTime endByDate = new DateTime(2015, 12, 31); | |
DueDate = DueDate.Add(ts); | |
endByDate = endByDate.Add(ts); | |
MapiTask task = new MapiTask("This is test task", "Sample Body", StartDate, DueDate); | |
task.State = MapiTaskState.NotAssigned; | |
// Set the Monthly recurrence | |
var rec = new MapiCalendarMonthlyRecurrencePattern | |
{ | |
Day = 15, | |
Period = 1, | |
PatternType = MapiCalendarRecurrencePatternType.Month, | |
EndType = MapiCalendarRecurrenceEndType.EndAfterNOccurrences, | |
OccurrenceCount = GetOccurrenceCount(StartDate, endByDate, "FREQ=MONTHLY;BYMONTHDAY=15;INTERVAL=1"), | |
WeekStartDay = DayOfWeek.Monday, | |
}; | |
if (rec.OccurrenceCount == 0) | |
{ | |
rec.OccurrenceCount = 1; | |
} | |
task.Recurrence = rec; | |
//task.Save(dataDir + "Monthly_out.msg", TaskSaveFormat.Msg); |
La siguiente función se puede usar para calcular el número de eventos entre las dos fechas:
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
private static uint GetOccurrenceCount(DateTime start, DateTime endBy, string rrule) | |
{ | |
CalendarRecurrence pattern = new CalendarRecurrence(string.Format("DTSTART:{0}\r\nRRULE:{1}", start.ToString("yyyyMMdd"), rrule)); | |
DateCollection dates = pattern.GenerateOccurrences(start, endBy); | |
return (uint)dates.Count; | |
} |
Establecer un número fijo de ocurrencias
El siguiente fragmento de código te muestra cómo establecer un número fijo de ocurrencias.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// Set the Monthly recurrence | |
var records = new MapiCalendarMonthlyRecurrencePattern | |
{ | |
Day = 15, | |
Period = 1, | |
PatternType = MapiCalendarRecurrencePatternType.Month, | |
EndType = MapiCalendarRecurrenceEndType.EndAfterNOccurrences, | |
OccurrenceCount = 5, | |
WeekStartDay = DayOfWeek.Monday | |
}; |
Recurrencias Mensuales: Tipo de Recurrencia EndAfterDate
La opción “End By” en la tarea Mapi se logra estableciendo la propiedad OccurrenceCount calculada por la función GetOccurrenceCount(). Esta función toma la fecha de inicio, la fecha de fin y la cadena RRULE. El siguiente fragmento de código te muestra cómo crear una recurrencia el día 15 de cada mes entre la fecha de inicio y la fecha de fin.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_Outlook(); | |
TimeZone localZone = TimeZone.CurrentTimeZone; | |
TimeSpan ts = localZone.GetUtcOffset(DateTime.Now); | |
DateTime StartDate = new DateTime(2015, 7, 1); | |
StartDate = StartDate.Add(ts); | |
DateTime DueDate = new DateTime(2015, 7, 1); | |
DateTime endByDate = new DateTime(2015, 12, 31); | |
DueDate = DueDate.Add(ts); | |
endByDate = endByDate.Add(ts); | |
MapiTask task = new MapiTask("This is test task", "Sample Body", StartDate, DueDate); | |
task.State = MapiTaskState.NotAssigned; | |
// Set the Monthly recurrence | |
var recurrence = new MapiCalendarMonthlyRecurrencePattern | |
{ | |
Day = 15, | |
Period = 1, | |
PatternType = MapiCalendarRecurrencePatternType.Month, | |
EndType = MapiCalendarRecurrenceEndType.EndAfterDate, | |
OccurrenceCount = GetOccurrenceCount(StartDate, endByDate, "FREQ=MONTHLY;BYMONTHDAY=15;INTERVAL=1"), | |
WeekStartDay = DayOfWeek.Monday, | |
EndDate = endByDate | |
}; | |
task.Recurrence = recurrence; | |
//task.Save(dataDir + "SetMonthlyEndAfterDateRecurrence_out.msg", TaskSaveFormat.Msg); |
Recurrencias Mensuales: Tipo de Recurrencia NeverEnd
El siguiente fragmento de código te muestra cómo establecer el tipo de fin utilizando MapiCalendarRecurrenceEndType.NeverEnd.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
var recurrence = new MapiCalendarMonthlyRecurrencePattern | |
{ | |
Day = 15, | |
Period = 1, | |
PatternType = MapiCalendarRecurrencePatternType.Month, | |
EndType = MapiCalendarRecurrenceEndType.NeverEnd, | |
WeekStartDay = DayOfWeek.Monday, | |
}; |
Trabajando con Recurrencias Anuales
Aspose.Email soporta la creación de recurrencias anuales utilizando MapiCalendarMonthlyRecurrencePattern. Al establecer la propiedad de período en 12, podemos lograr el patrón de recurrencia anual. Se pueden usar tres tipos diferentes de fin de recurrencia del calendario Mapi, incluyendo EndAfterNOccurrences, EndAfterDate y NeverEnd. Esta sección demuestra la creación de diferentes patrones de recurrencia anual.
Recurrencias Anuales: Tipo de Recurrencia EndAfterNOccurrences
En este tipo de recurrencia, se debe establecer el número de recurrencias junto con otra información de la siguiente manera:
- Establecer la fecha de inicio, fin y fecha de vencimiento.
- Crear una MapiTask.
- Establecer el estado de la tarea a NotAssigned.
- Crear el objeto de recurrencia mensual configurando propiedades como PatternType, Period, WeekStartDay, EndType y OccurenceCount.
- Establecer la propiedad MapiTask.Recurrence a este objeto de recurrencia mensual para lograr la recurrencia anual.
- Guardar este mensaje en disco.
El siguiente fragmento de código te muestra cómo crear una tarea con el tipo de fin de recurrencia como EndAfterNOccurrence.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
TimeZone localZone = TimeZone.CurrentTimeZone; | |
TimeSpan ts = localZone.GetUtcOffset(DateTime.Now); | |
DateTime StartDate = new DateTime(2015, 7, 1); | |
StartDate = StartDate.Add(ts); | |
DateTime DueDate = new DateTime(2015, 7, 1); | |
DateTime endByDate = new DateTime(2020, 12, 31); | |
DueDate = DueDate.Add(ts); | |
endByDate = endByDate.Add(ts); | |
MapiTask task = new MapiTask("This is test task", "Sample Body", StartDate, DueDate); | |
task.State = MapiTaskState.NotAssigned; | |
// Set the Yearly recurrence | |
var recurrence = new MapiCalendarMonthlyRecurrencePattern | |
{ | |
Day = 15, | |
Period = 12, | |
PatternType = MapiCalendarRecurrencePatternType.Month, | |
EndType = MapiCalendarRecurrenceEndType.EndAfterNOccurrences, | |
OccurrenceCount = 3, | |
}; | |
task.Recurrence = recurrence; | |
task.Save("Yearly.msg", TaskSaveFormat.Msg); |
Recurrencias Anuales: Tipo de Recurrencia EndAfterDate
La opción “End By” en la tarea Mapi se logra estableciendo la propiedad OccurrenceCount calculada por la función GetOccurrenceCount(). Esta función toma la fecha de inicio, la fecha de fin y la cadena RRULE. El siguiente fragmento de código te muestra cómo crear una recurrencia el día 15 de cada 7º mes entre la fecha de inicio y la fecha de fin.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// Set the Yearly recurrence | |
var rec = new MapiCalendarMonthlyRecurrencePattern | |
{ | |
Day = 15, | |
Period = 12, | |
PatternType = MapiCalendarRecurrencePatternType.Month, | |
EndType = MapiCalendarRecurrenceEndType.EndAfterDate, | |
EndDate = endByDate, | |
OccurrenceCount = GetOccurrenceCount(StartDate, endByDate, "FREQ=YEARLY;BYMONTHDAY=15;BYMONTH=7;INTERVAL=1"), | |
}; | |
task.Recurrence = rec; |
Recurrencias Anuales: Tipo de Recurrencia NeverEnd
El siguiente fragmento de código te muestra cómo establecer el tipo de fin utilizando MapiCalendarRecurrenceEndType.NeverEnd.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// Set the Yearly recurrence | |
var recurrence = new MapiCalendarMonthlyRecurrencePattern | |
{ | |
Day = 15, | |
Period = 12, | |
PatternType = MapiCalendarRecurrencePatternType.Month, | |
EndType = MapiCalendarRecurrenceEndType.NeverEnd, | |
}; |
Generar Recurrencia a partir de Regla de Recurrencia
La API Aspose.Email proporciona la capacidad de generar un Patrón de Recurrencia a partir de una Regla de Recurrencia (RRULE). Analiza la información de la RRULE según las especificaciones iCal de RFC 5545 y genera el patrón de recurrencia utilizando el método MapiCalendarRecurrencePatternFactory.FromString. El siguiente fragmento de código te muestra cómo generar el patrón de recurrencia a partir de la regla de recurrencia.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
// The path to the File directory. | |
string dataDir = RunExamples.GetDataDir_Outlook(); | |
DateTime startDate = new DateTime(2015, 7, 16); | |
DateTime endDate = new DateTime(2015, 8, 1); | |
MapiCalendar app1 = new MapiCalendar("test location", "test summary", "test description", startDate, endDate); | |
app1.StartDate = startDate; | |
app1.EndDate = endDate; | |
string pattern = "DTSTART;TZID=Europe/London:20150831T080000\r\nDTEND;TZID=Europe/London:20150831T083000\r\nRRULE:FREQ=DAILY;INTERVAL=1;COUNT=7\r\nEXDATE:20150831T070000Z,20150904T070000Z"; | |
app1.Recurrence.RecurrencePattern = MapiCalendarRecurrencePatternFactory.FromString(pattern); |
Añadir un Archivo Adjunto a Eventos de Calendario Recurrentes
La API Aspose.Email proporciona la capacidad de agregar archivos adjuntos a eventos de calendario recurrentes.
// For complete examples and data files, please go to https://github.com/aspose-email/Aspose.Email-for-.NET | |
DateTime startDate = new DateTime(2018, 7, 19).AddHours(12); | |
MapiCalendar calendar = new MapiCalendar("location1", "summary1", "description1", startDate, startDate.AddHours(1)); | |
MapiCalendarEventRecurrence recurrence = new MapiCalendarEventRecurrence(); | |
MapiCalendarRecurrencePattern pattern = recurrence.RecurrencePattern = new MapiCalendarDailyRecurrencePattern(); | |
pattern.PatternType = MapiCalendarRecurrencePatternType.Day; | |
pattern.Period = 1; | |
pattern.EndType = MapiCalendarRecurrenceEndType.NeverEnd; | |
DateTime exceptionDate = startDate.AddDays(3); | |
MapiCalendarExceptionInfo exception = new MapiCalendarExceptionInfo | |
{ | |
Location = "exceptionLoc", | |
Subject = "exceptionSubj", | |
Body = "exceptionBody", | |
OriginalStartDate = exceptionDate, | |
StartDateTime = exceptionDate, | |
EndDateTime = exceptionDate.AddHours(5), | |
Attachments = new MapiAttachmentCollection(calendar) | |
}; | |
exception.Attachments.Add("file.txt", Encoding.ASCII.GetBytes("hello, world!")); | |
pattern.Exceptions.Add(exception); | |
pattern.ModifiedInstanceDates.Add(exceptionDate); | |
pattern.DeletedInstanceDates.Add(exceptionDate); | |
calendar.Recurrence = recurrence; | |
using (var newPst = PersonalStorage.Create(dataDir + "AddAttachmentToMapiExceptionInfo.pst", FileFormatVersion.Unicode)) | |
{ | |
var newFolder = newPst.CreatePredefinedFolder("Calendar", StandardIpmFolder.Appointments); | |
newFolder.AddMapiMessageItem(calendar); | |
} |