Skip to content

ICS Already Include in Body for Outlook/Gmail... but not for Office 365 #143

Closed

Description

@RulianZB

Hi, i got a big problems with the mail including ICS.
I am using Laravel 11 and spatie/icalendar-generator 2.8

First i was including the ICS like an attachment :

attachData($this->generateLeaveICS($this->data['leave']), 'name.ics', [
    'mime' => 'text/calendar; charset=UTF-8; method=REQUEST',
])

But our security blocks ICS files, so I had to include these ICS directly in the body of the Mail via a symphony function.

$mailable->withSymfonyMessage(function (Email $email) use ($leave, $mailable) {
     $ics = $this->generateLeaveICS($leave);

     $htmlContent = (string) $mailable->markdown('mailing::email')->render();

     $htmlPart = new TextPart($htmlContent, 'utf-8', 'html');
     $calendarPart = new TextPart($ics, 'utf-8', 'calendar');

     $email->setBody(new MixedPart($htmlPart, $calendarPart));
});

Since I put this code in place, the invitation is interpreted correctly by Outlook and Gmail, but keeps an ICS file named ATT00001.ics on outlook.office365.com. However, I added specific headers to MSO such as X-MS-Has-Attach, X-MS-TNEF-Correlator, Accept-Language, Content-Language, x-ms-exchange-calendar-series-instance- id. I even tried to transform multipart/mixed into multipart/alternative but without any success. Do you have any ideas that could help me move forward on this issue?

Here is my ICS content that is validated by iCalendar Validator :

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Microsoft Corporation//Outlook 16.0 MIMEDIR//EN
NAME:CONGES
X-WR-CALNAME:CONGES
METHOD:REQUEST
BEGIN:VEVENT
UID:670e87ac9b0fe
DTSTAMP:20241015T151804Z
SUMMARY:CONGES
ATTENDEE;CN=Admin:MAILTO:test@test.fr
DTSTART:20241017T000000
DTEND:20241017T235900
END:VEVENT
END:VCALENDAR

Activity

  1. locked and limited conversation to collaborators on Dec 11, 2024
  2. converted this issue into a discussion #147 on Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions