Support the ongoing development of Laravel.io →
posted 10 years ago
Mail
Last updated 1 year ago.
0

Do it this way, bro:

	\Mail::send('yourMail/file', $data, function($message) use($data)
	{
		$filename = "invite.ics";
		$meeting_duration = (3600 * 2); // 2 hours
		$meetingstamp = strtotime( $data['start_date'] . " UTC");
		$dtstart = gmdate('Ymd\THis\Z', $meetingstamp);
		$dtend =  gmdate('Ymd\THis\Z', $meetingstamp + $meeting_duration);
		$todaystamp = gmdate('Ymd\THis\Z');
		$uid = date('Ymd').'T'.date('His').'-'.rand().'@yourdomain.com';
		$description = strip_tags($data['texto']);
		$location = "Telefone ou vídeo conferência";
		$titulo_invite = "Your meeting title";
		$organizer = "CN=Organizer name:[email protected]";
		
		// ICS
		$mail[0]  = "BEGIN:VCALENDAR";
		$mail[1] = "PRODID:-//Google Inc//Google Calendar 70.9054//EN";
		$mail[2] = "VERSION:2.0";
		$mail[3] = "CALSCALE:GREGORIAN";
		$mail[4] = "METHOD:REQUEST";
		$mail[5] = "BEGIN:VEVENT";
		$mail[6] = "DTSTART;TZID=America/Sao_Paulo:" . $dtstart;
		$mail[7] = "DTEND;TZID=America/Sao_Paulo:" . $dtend;
		$mail[8] = "DTSTAMP;TZID=America/Sao_Paulo:" . $todaystamp;
		$mail[9] = "UID:" . $uid;
		$mail[10] = "ORGANIZER;" . $organizer;
		$mail[11] = "CREATED:" . $todaystamp;
		$mail[12] = "DESCRIPTION:" . $description;
		$mail[13] = "LAST-MODIFIED:" . $todaystamp;
		$mail[14] = "LOCATION:" . $location;
		$mail[15] = "SEQUENCE:0";
		$mail[16] = "STATUS:CONFIRMED";
		$mail[17] = "SUMMARY:" . $titulo_invite;
		$mail[18] = "TRANSP:OPAQUE";
		$mail[19] = "END:VEVENT";
		$mail[20] = "END:VCALENDAR";
		
		$mail = implode("\r\n", $mail);
		header("text/calendar");
		file_put_contents($filename, $mail);
		
		$message->subject($data['titulo']);
		$message->to($data['destinatario']);
	    $message->attach($filename, array('mime' => "text/calendar"));
	});

Regards,

David

Last updated 8 years ago.
0

@davidtoledo

Thank you for your snippet.

0

@davidtoledo

Thanks for your snippet. It's working in gmail but not working in outlook. I am getting 'The .ICS attachment can't be viewed because the format is not supported.' Please let me know where the problem is?

0

@muralibobby35 and @davidtoledo

That'e exactly what I am doing through "t's working in gmail but not working in outlook", did you find the fix of this issue?

0

Did you guys find a way to make this work on outlook? I still get the .ics as an attachment instead of the buttons to accept or decline.. Please help

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Osvalds osvalds Joined 12 Mar 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.