Franz Kiermaier
Franz Kiermaier

Reputation: 397

Add an alert to an event in Ical.net

I am using ical.net to provide outlook internet calendar integration for my solution.

I have several events from 00:00 a.m. to 00:00 a.m. (next day). When I add an alarm to the events, in Outlook these events show with no alert.

This is the code how I added the alarms and events.

    foreach (var taskItem in taskItems.Where(t => t.DueDate != null && t.DueDate.HasValue == true))
    {
        var hyperlink = Request.GetBaseUrl();

        hyperlink = string.Format("{0}/TaskBoard/Tasks?listId={1}", hyperlink, taskItem.ListId);
        var dueDate = new DateTime(taskItem.DueDate.Value.Ticks, DateTimeKind.Utc);
        var alarm = new Alarm()
        {
            Summary = taskItem.Title,
            Trigger = new Trigger(TimeSpan.FromMinutes(-15)),
            Action = AlarmAction.Display
        };

        var calendarEvent = new Event
        {
            Class = "PUBLIC",
            Summary = taskItem.Title,
            Created = new CalDateTime(taskItem.Created.Value),
            Description = string.Format("Open board: {0}", hyperlink),
            Start = new CalDateTime(dueDate),
            End = new CalDateTime(dueDate.AddDays(1)),
            Uid = taskItem.Id.ToString(),
            Location = taskItem.ListTitle
        };

        calendarEvent.Alarms.Add(alarm);
        calendar.Events.Add(calendarEvent);
    }

this is the resulting iCal file content

BEGIN:VCALENDAR
PRODID:-//github.com/rianjs/ical.net//NONSGML ical.net 2.2//EN
VERSION:2.0
X-WR-CALNAME:Agile Kanban - Meine Aufgaben
BEGIN:VEVENT
CLASS:PUBLIC
CREATED:20170814T114839
DESCRIPTION:Open board: https://localhost:44300/TaskBoard/Tasks?listId=637
 90e98-cacc-4f03-992f-f3276db06dda
DTEND:20170827T220000Z
DTSTAMP:20170829T170757Z
DTSTART:20170826T220000Z
LOCATION:Room1
SEQUENCE:0
SUMMARY:Task changed
UID:1d4b10bf-7434-41d9-8dd2-311e3679b0a7
BEGIN:VALARM
ACTION:Display
SUMMARY:Task changed
TRIGGER:-PT15M
END:VALARM
END:VEVENT
END:VCALENDAR

Upvotes: 3

Views: 3661

Answers (1)

Arnaud Quillaud
Arnaud Quillaud

Reputation: 4645

How are the event added to Outlook ?

If they are made available as an http subscription, Outlook is probably ignoring it on purpose. How one wants to be notified in advance is a really a personal choice so calendar clients tend to ignore alarms from outside sources, whether added via an invitations (see Sent email with iCal to outlook with valarm reminder ) or via public calendar subscriptions.

If you are doing an import of the task and the alarms still do not show up, there might be a problem with your iCalendar stream so seing the actual iCalendar stream instead of your code would be more useful.

Finally, I vaguely remember Outlook handling only absolute alarms (see https://www.rfc-editor.org/rfc/rfc5545#section-3.8.6.3) for VTODO but I do not know whether it is still the case.

Upvotes: 1

Related Questions