IchLiebeKadarka
IchLiebeKadarka

Reputation: 65

ICalendar (ICS) - only VEVENT components works good with outlook/googleCalendar

I've got some problems with generating Icalendar files (*.ICS) Im using library Ical.NET and c# language.

Code is very simple, for example this is VEVENT:

  public override void HandleComponent(Ical.Net.Calendar root, CalendarData data)
  {
            var icalEvent = new Ical.Net.Event();
            icalEvent.Start = new CalDateTime(data.Poczatek);
            icalEvent.End = new CalDateTime(data.Koniec);
            icalEvent.Location = data.Lokalizacja;
            icalEvent.Description = data.Opis;
            icalEvent.Summary = data.Nazwa;
            root.Events.Add(icalEvent);
  }

VJOURNEY and VTODO have very similar code <-- firstly i'm creating component, and then add it to calendar object.

Then i have generated file from this code:

var serializer = new CalendarSerializer(calendar);
var icsContent = serializer.SerializeToString();
return icsContent;

and structure of ics files looks like:

BEGIN:VCALENDAR
PRODID:-//github.com/rianjs/ical.net//NONSGML ical.net 2.2//EN
VERSION:2.0
BEGIN:VJOURNAL
ATTENDEE;CN=a;RSVP=TRUE;ROLE=REQ-PARTICIPANT:mailto:[email protected]
ATTENDEE;CN=a2;RSVP=TRUE;ROLE=REQ-PARTICIPANT:mailto:[email protected]
DESCRIPTION:trele morele
DTSTAMP:20180913T072413Z
DTSTART:20180912T130700
ORGANIZER;CN=Administrator:mailto:[email protected]
SEQUENCE:1
SUMMARY:qwerty22
UID:97032fa5-f554-4f10-9c4d-4fdda38148c7
END:VJOURNAL
END:VCALENDAR

just like specification says: https://www.kanzaki.com/docs/ical/vjournal.html

Problem:

Both Outlook 2016, and GoogleCalender handle properly only with VEVENT components on ICalendar file. When i import VJOURNAL or VTODO in GoogleCalendar it responds that he doesn't se any event... Am i doing something wrong?

I also paste code where i create VJOURNAL

   public class CalendarJournalComponent : CalendarComponents
    {
        public override CalendarComponentType SupportedComponent => CalendarComponentType.Journal;

        public override void HandleComponent(Ical.Net.Calendar root, CalendarData data)
        {
            var journal = new Journal();
            journal.Start = new CalDateTime(data.Poczatek);
            journal.Description = data.Opis;
            journal.Summary = data.Nazwa;

            if (data.Prowadzacy.Any())
            {
                var prowadzacy = data.Prowadzacy.FirstOrDefault();
                journal.Organizer = new Organizer() { CommonName = prowadzacy.Value, Value = emailUri(prowadzacy.Key)};
            }

            journal.Attendees = new List<IAttendee>();

            foreach(var uczesnik in data.Uczestnicy)
            {
                journal.Attendees.Add(new Attendee() { CommonName = uczesnik.Value, Rsvp = true, Value = emailUri(uczesnik.Key), Role = "REQ-PARTICIPANT" });
            }
            root.Journals.Add(journal);
        }

        private Func<string, Uri> emailUri = x => new Uri(String.Format("mailto:{0}", x));
    }

and VTODO compoment:

  public class CalendarTodoComponent : CalendarComponents
    {
        public override CalendarComponentType SupportedComponent => CalendarComponentType.ToDo;

        public override void HandleComponent(Ical.Net.Calendar root, CalendarData data)
        {
            var todo = new Todo();
            todo.Start = new CalDateTime(data.Poczatek);
            todo.Description = data.Opis;
            todo.Summary = data.Nazwa;
            todo.Location = data.Lokalizacja;
            root.Todos.Add(todo);
        }
    }

Upvotes: 0

Views: 1029

Answers (1)

Arnaud Quillaud
Arnaud Quillaud

Reputation: 4645

Your code is most likely fine. But you need to ask yourself what you really expect to do by trying to import those VJOURNAL and VTODO in Google Calendar ? As of today, Google Calendar really only support events/meetings:

  • It does not support VJOURNAL. As a matter of fact, there are really few software which do support VJOURNAL. From its definition (https://www.rfc-editor.org/rfc/rfc5545#section-3.6.3) you will see that it could be seen as the ancestor of a blog entry.
  • It does not support VTODO either. The closest you could find would be in Gmail which has a notion of Tasks list.

Upvotes: 1

Related Questions