spatie / calendar-links

Generate add to calendar links for Google, iCal and other calendar systems
https://spatie.be/opensource
MIT License
914 stars 149 forks source link

$link->ics() can't be attached on email #91

Closed F3rrY closed 4 years ago

F3rrY commented 4 years ago

Hi!

I'm doing a project with Laravel and I want to make links to create appointments to Google Calendar, Outlook, etc. So, this works perfect, but when I want to attach the link->ics() into a link or create a ics file to be attached in the mail, it doesn't work.

For example. If I make this:

var $example = $link->ics();

This generate the "data:text/calendar;charset=utf8;base64,...". So, if I put this in a a href="" attribute, when I click from outlook Windows ask me how can open this, because Windows don't know how to open.

And, if I put the $link->ics() in a file using file_put_contents($filepath, $link->ics() and then I attach to the mail like this:

Mail->send(new MailTemplate(), function($message) use ($filename) { $message->attachFromStorage($filename,'example.ics', ['mime' => 'text/calendar']); });

And I tried this:

`$file_to_attach = 'data:text/calendar;charset=utf8;base64,QkVHSU4...'

Mail->send(new MailTemplate(), function($message) use ($file_to_attach ) { $message->attachData($file_to_attach ,'example.ics'); });`

And this:

`$file_to_attach = 'data:text/calendar;charset=utf8;base64,QkVHSU4...'

Mail->send(new MailTemplate(), function($message) use ($file_to_attach ) { $message->attach($file_to_attach , ['as' => 'meeting.ics','mime' => 'text/calendar']); });`

And sent the mail but in Outlook don't show me any attached file.

What could be happen?

alies-dev commented 4 years ago

@F3rrY i think it's connected to https://github.com/spatie/calendar-links/issues/71

it's a limitation of mail client, must likely we can't do anything with it.

you can try to implement a custom generator for emails using json-ld syntax https://developers.google.com/gmail/markup/reference/formats/json-ld

this topic can also help you https://stackoverflow.com/questions/57371445/schema-org-markup-in-emails

F3rrY commented 4 years ago

Hi! It's solved.

The error was caused by me when mounting the template view (which extends from Mailable). There I didn't indicate that I want to attach something.

So, in the class when I build the mail I put attachData specifying the information to save and the name of the file. And yes, it appears in Outlook.

Thanks and sorry!