composer require linktoahref/vevent
use LTAH\Generator\VEvent;
$event = VEvent::create('Event Summary or Title', new DateTime('2018-05-10'), new DateTime('2018-05-11'));
$event->addOrganizer('Organizer Name', 'test@mail.com');
$event->addAttendees('Attendee Name', 'foo@bar.com');
echo $event->render();
If using Laravel you could modify the Mailable class's withSwiftMessage
method
within the build
method
$this->markdown('emails.mailable')
->with([ params ]);
$this->withSwiftMessage(function ($message) use ($ical, $subject) {
$message->setBody($event->render(), 'text/calendar; charset="utf-8"; method=REQUEST');
$message->addPart($this->buildView()['html']->toHtml(), 'text/html');
});
return
$this->subject($subject)
->attachData($event->render(), 'meeting.ics', [
'mime' => 'text/calendar; charset="utf-8"; method=REQUEST',
]);
This would render the event with styling in gmail and outlook