title: Generate and Send .ics file via Symfony2 (Swift Mailer)
body: <p>I am trying to generate a calendar event MS Outlook/Google Calendar in Symfony2, while the email is sent with .ics file but I am not able to get the event added to calendar. When I try to open the file it says </p>
  
  <pre><code>Failed to import events: Unable to process your iCal/CSV file..
  </code></pre>
  
  <p>This is how I am trying to generate the iCal file</p>
  
  <pre><code>$message="
      BEGIN:VCALENDAR
      VERSION:2.0
      CALSCALE:GREGORIAN
      METHOD:REQUEST
      BEGIN:VEVENT
      DTSTART:".date('Ymd\THis', strtotime($meetingStartTime))."
      DTEND:".date('Ymd\THis', strtotime($meetingEndTime))."
      DTSTAMP:".date('Ymd\THis', strtotime($meetingStartTime))."
      ORGANIZER;CN=XYZ:mailto:do-not-reply@example.com
      UID:".rand(5, 1500)."
      ATTENDEE;PARTSTAT=NEEDS-ACTION;RSVP= TRUE;CN=Sample:emailaddress@testemail.com
      DESCRIPTION:".$this-&gt;getUser()-&gt;getName()." requested Phone/Video Meeting Request
      LOCATION: Phone/Video
      SEQUENCE:0
      STATUS:CONFIRMED
      SUMMARY:Meeting has been scheduled by ".$this-&gt;getUser()-&gt;getName()."
      TRANSP:OPAQUE
      END:VEVENT
      END:VCALENDAR";
  
  $messageObject = \Swift_Message::newInstance();
  $messageObject-&gt;setContentType("text/calendar");
  $messageObject-&gt;setSubject("Your meeting has been booked")
                -&gt;setFrom($this-&gt;container-&gt;getParameter('mailer_user'), "From Name")
                -&gt;setTo($this-&gt;getUser()-&gt;getEmail())
                -&gt;setBody(trim($message));
  $this-&gt;get('mailer')-&gt;send($messageObject);
  </code></pre>
  
  <p>I will really appreciate if I can get some help on what I am doing wrong which leads to the error of <strong>Failed to import events: Unable to process your iCal/CSV file</strong></p>