2

I have a piece of code that looks like the code bellow. It creates a Swift Attachment and creates a Swift mail. As part of the mail I also included the content of the ics (I found some code that did that, but doesn't help).

The problem is that the ics is not recognized as an event in Hotmail. Only in the inbox summary line a event logo is added, but when the e-mail is opened it doesn't show the usual event invite overview.

        $attachment = \Swift_Attachment::fromPath($location, 'application/ics')->setFileName('invite.ics')->setDisposition('inline');
        $contents = file_get_contents($location);
        $message = \Swift_Message::newInstance()
                    ->setSubject('Title')
                    ->setFrom($this->fromMail)
                    ->setTo($email)
                    ->setBody($this->renderView('PastonVerBundle:Mail:invite.text.twig', $parameters))
                    ->addPart($this->renderView('PastonVerBundle:Mail:invite.html.twig', $parameters), 'text/html')
                    ->addPart($contents, 'text/calendar')
                    ->attach($attachment)
            ;

Example of an ics

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//PASTON-12//NONSGML kigkonsult.se iCalcreator 2.10.23//
X-WR-CALNAME:safsafasdf345541111
X-WR-CALDESC:asdfasdfasdf
X-WR-TIMEZONE:Africa/Johannesburg
BEGIN:VEVENT
UID:20120305T150831CET-0008haHjvH@PASTON-12
DTSTAMP:20120305T140831Z
DESCRIPTION:asdfasdfasdf
DTSTART:20120129T000000Z
DTEND:20120229T010000Z
LOCATION:
SUMMARY:safsafasdf345541111
END:VEVENT
END:VCALENDAR
Roel Veldhuizen
  • 4,613
  • 8
  • 44
  • 78
  • Have you tried using the same content-type for both elements, and possibly just including one instead of both? Do you have an example of the generated ics file? Does it work in other ics compatible applications, such as Google Calendar? – MatsLindh Mar 30 '12 at 23:17
  • @fiskfisk, added an example ics. In gmail it works fine. It does'nt really matter what headers are used or whether the ics is attached inline or not. Only hotmail seems to be extremly strict. – Roel Veldhuizen Apr 02 '12 at 08:46
  • This seems to be more of a question of your client than a question of content type or [the mimetype you're sending over the wire](https://en.wikipedia.org/wiki/ICalendar). The biggest clue is [Hotmail's official guidance on importing calendar items,](http://windows.microsoft.com/en-US/hotmail/calendar-subscribe-calendar-ui) which cheerfully omits the possibility of importing ICS files from within the web client. Do you have documentation that states otherwise? – MrGomez Apr 02 '12 at 23:57
  • 1
    @MrGomez if you send an invite from google calendar, then hotmail shows the ics correctly. So, no documentation but a working example – Roel Veldhuizen Apr 03 '12 at 07:29

0 Answers0