Calendar invitation accepted as ICS file in Outlook - Laravel

I am sending a calendar invitation using the Larvel mail api.

The calendar looks great in gmail, but shows an attachment in Outlook instead of the correct calendar invitation.

Gmail output:

enter image description here

, while in appearance it looks like affection:

enter image description here

I create a file called invite.ics and I put the contents in the invitation file. I attach the file when sending a message.

$to = $row->to; $subject = $row->subject; $attachments = $row->attachment; $cc = $row->cc; $body = $row->body; $calendar_invitation = $row->calendar_invitation; \Mail::send( 'emailTemplates.dummy', ['emailBody'=>$row->body], function(Message $message) use ($to,$subject,$attachments,$cc, $body, $calendar_invitation, $companyEmail) { $message->from($companyEmail, ''); $message->replyTo($companyEmail, 'Email Agent Evmeetings'); $message->to($to, '')->subject($subject); $file = fopen("invite.ics","w"); echo fwrite($file,$calendar_invitation); fclose($file); $message->attach('invite.ics', array('mime' => "text/calendar")); }); 
+7
php outlook calendar laravel-5
source share
1 answer

How i made it work

 $message->from($companyEmail, ''); $message->replyTo($companyEmail, 'Email Agent Evmeetings'); $message->to($to, '')->subject($subject); $message->setBody($calendar_invitation, 'text/calendar; charset="utf-8"; method=REQUEST'); $message->addPart($body, "text/html"); 

Added a calendar to the body and changed the mime type to 'text/calendar; charset="utf-8"; method=REQUEST' 'text/calendar; charset="utf-8"; method=REQUEST'

and use the addPart($body, "text/html"); method addPart($body, "text/html"); to add the html body to the email.

+4
source share

All Articles