title: Mailgun: send calendar meeting event / request
body: <p>I've got problem with sending calendar event that is recognized by Outlook and iOS mail app as calendar event and not ordinary email.</p>
  
  <p>I'm using JavaScript in node.js env. To send email I'm using mailgun and js library <code>mailgun-js</code>. I'm creating ics file and attaching it to the email.</p>
  
  <pre><code> const mailgun = require('mailgun-js')({apiKey: mailgunApiKey, domain: mailgunDomain})
  
   const candidateEmailBody = {
      from: `${companyName} &lt;${EMAIL_FROM}&gt;`,
      to: email,
      subject: companyName + ' - interview',
      html: 'Html message',
      attachment: [invite]
  
    }
  
    mailgun.messages().send(candidateEmailBody, function (error, body) {
      if (error) {
        console.log(error)
      }
    })
  </code></pre>
  
  <p>The <code>invite</code> object is created by <code>ics</code> lib and wrapped in mailgun attachement by the function below:</p>
  
  <pre><code>const prepareIcsInvite = function (startDate, companyName, firstname, lastname, email, intFirstname, intLastname, intEmail) {
    const st = new Date(startDate)
    const meetingEvent = {
      start: [st.getFullYear(), st.getMonth() + 1, st.getDate(), st.getHours(), st.getMinutes()],
      end: [st.getFullYear(), st.getMonth() + 1, st.getDate(), st.getHours()+1, st.getMinutes()],
      title: companyName + ' - Interview',
      description: 'description',
      location: 'location',
      status: 'CONFIRMED',
      productId: 'myproduct',
      organizer: {name: 'Admin', email: 'admin@example.com'},
      attendees: [
        {name: firstname + ' ' + lastname, email: email},
        {name: intFirstname + ' ' + intLastname, email: intEmail}
      ]
    }
  
    const icsFile = ics.createEvent(meetingEvent)
    const fileData = new Buffer(icsFile.value)
  
    const invite = new mailgun.Attachment(
      {
        data: fileData,
        filename: 'Meeting Invite.ics',
        contentType: 'text/calendar'
      })
    console.log('ICS meeting invite created')
    return invite
  }
  </code></pre>
  
  <p>Email prepared that way is sent via mailgun API and GMail correctly recognizes it as meeting invitation:</p>
  
  <p><a href="https://i.stack.imgur.com/HGlW2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HGlW2.png" alt="enter image description here"></a></p>
  
  <p>However, other email clients (iOS, Outlook) don't recognize that this is calendar event invitation and just display it as ordinary email, with a file attachment.</p>
  
  <p>What should I do to make this message Outlook and iOS compatible?</p>