Calendar invite is received as ICS file in outlook - Laravel

Viewed 3728

I am sending calendar invite using Laravel's mail api.

The calendar looks good on gmail but shows an attachment on outlook instead of proper calendar invitation.

Gmail's output:

enter image description here

while on outlook it seems to be an attachment:

enter image description here

I am creating a file with name invite.ics and I put the content inside the invite.ics file, I attach the file while sending the email.

$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"));


});
1 Answers
Related