I am using ical4j to generate a calendar with 2 events. I have generated the following ics file:
BEGIN:VCALENDAR
PRODID:-//Events Calendar//iCal4j 1.0//EN
CALSCALE:GREGORIAN
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
DTSTAMP:20210823T123718Z
DTSTART:20210810T090000
DTEND:20210810T100000
SUMMARY:Test event 1
UID:b9b49cb5-b207-4faa-9fb8-a435b455b3b1
END:VEVENT
BEGIN:VEVENT
DTSTAMP:20210823T123718Z
DTSTART:20210809T090000
DTEND:20210809T100000
SUMMARY:Test event 2
UID:46b04290-75b1-4651-a5b3-5a0b2ace3ad5
END:VEVENT
END:VCALENDAR
When I open it in Outlook, it creates a new calendar called "Untitled" in the "Other Calendars" section, and adds the two events.
How can I make sure that the events are added to the user's default/main calendar instead?
It could be that Outlook treats a calendar object with multiple events (i.e. events with different UID values) differently to single event calendar objects.
Note that this is entirely up to the CUA implementation, so I can't be 100% certain, but I would suggest to try sending as separate calendar objects for each different event (not sure if you can attach multiple in one email or would need separate delivery).
You may also want to try sending them in the same attachment as follows:
BEGIN:VCALENDAR
PRODID:-//Events Calendar//iCal4j 1.0//EN
CALSCALE:GREGORIAN
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
DTSTAMP:20210823T123718Z
DTSTART:20210810T090000
DTEND:20210810T100000
SUMMARY:Test event 1
UID:b9b49cb5-b207-4faa-9fb8-a435b455b3b1
END:VEVENT
END:VCALENDAR
BEGIN:VCALENDAR
PRODID:-//Events Calendar//iCal4j 1.0//EN
CALSCALE:GREGORIAN
VERSION:2.0
METHOD:PUBLISH
BEGIN:VEVENT
DTSTAMP:20210823T123718Z
DTSTART:20210809T090000
DTEND:20210809T100000
SUMMARY:Test event 2
UID:46b04290-75b1-4651-a5b3-5a0b2ace3ad5
END:VEVENT
END:VCALENDAR