Requests a new event be created in the store.

  http://msdn.microsoft.com/en-us/library/aa564690(v=exchg.140).aspx

  <m:CreateItem SendMeetingInvitations="SendToAllAndSaveCopy"
              xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
              xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
    <m:SavedItemFolderId>
        <t:DistinguishedFolderId Id="calendar"/>
    </m:SavedItemFolderId>
    <m:Items>
        <t:CalendarItem>
            <t:Subject>{event.subject}</t:Subject>
            <t:Body BodyType="HTML">{event.subject}</t:Body>
            <t:Start></t:Start>
            <t:End></t:End>
            <t:Location></t:Location>
            <t:RequiredAttendees>
                {% for attendee_email in meeting.required_attendees %}
                <t:Attendee>
                    <t:Mailbox>
                        <t:EmailAddress>{{ attendee_email }}</t:EmailAddress>
                    </t:Mailbox>
                </t:Attendee>
             HTTPretty   {% endfor %}
            </t:RequiredAttendees>
            {% if meeting.optional_attendees %}
            <t:OptionalAttendees>
                {% for attendee_email in meeting.optional_attendees %}
                    <t:Attendee>
                        <t:Mailbox>
                            <t:EmailAddress>{{ attendee_email }}</t:EmailAddress>
                        </t:Mailbox>
                    </t:Attendee>
                {% endfor %}
            </t:OptionalAttendees>
            {% endif %}
            {% if meeting.conference_room %}
            <t:Resources>
                <t:Attendee>
                    <t:Mailbox>
                        <t:EmailAddress>{{ meeting.conference_room.email }}</t:EmailAddress>
                    </t:Mailbox>
                </t:Attendee>
            </t:Resources>
            {% endif %}
            </t:CalendarItem>
    </m:Items>
</m:CreateItem>

def new_event(event):
  """
  Requests a new event be created in the store.

  http://msdn.microsoft.com/en-us/library/aa564690(v=exchg.140).aspx

  <m:CreateItem SendMeetingInvitations="SendToAllAndSaveCopy"
              xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages"
              xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
    <m:SavedItemFolderId>
        <t:DistinguishedFolderId Id="calendar"/>
    </m:SavedItemFolderId>
    <m:Items>
        <t:CalendarItem>
            <t:Subject>{event.subject}</t:Subject>
            <t:Body BodyType="HTML">{event.subject}</t:Body>
            <t:Start></t:Start>
            <t:End></t:End>
            <t:Location></t:Location>
            <t:RequiredAttendees>
                {% for attendee_email in meeting.required_attendees %}
                <t:Attendee>
                    <t:Mailbox>
                        <t:EmailAddress>{{ attendee_email }}</t:EmailAddress>
                    </t:Mailbox>
                </t:Attendee>
             HTTPretty   {% endfor %}
            </t:RequiredAttendees>
            {% if meeting.optional_attendees %}
            <t:OptionalAttendees>
                {% for attendee_email in meeting.optional_attendees %}
                    <t:Attendee>
                        <t:Mailbox>
                            <t:EmailAddress>{{ attendee_email }}</t:EmailAddress>
                        </t:Mailbox>
                    </t:Attendee>
                {% endfor %}
            </t:OptionalAttendees>
            {% endif %}
            {% if meeting.conference_room %}
            <t:Resources>
                <t:Attendee>
                    <t:Mailbox>
                        <t:EmailAddress>{{ meeting.conference_room.email }}</t:EmailAddress>
                    </t:Mailbox>
                </t:Attendee>
            </t:Resources>
            {% endif %}
            </t:CalendarItem>
    </m:Items>
</m:CreateItem>
  """

  id = T.DistinguishedFolderId(Id=event.calendar_id) if event.calendar_id in DISTINGUISHED_IDS else T.FolderId(Id=event.calendar_id)

  start = convert_datetime_to_utc(event.start)
  end = convert_datetime_to_utc(event.end)

  root = M.CreateItem(
    M.SavedItemFolderId(id),
    M.Items(
      T.CalendarItem(
        T.Subject(event.subject),
        T.Body(event.body or u'', BodyType="HTML"),
      )
    ),
    SendMeetingInvitations="SendToAllAndSaveCopy"
  )

  calendar_node = root.xpath(u'/m:CreateItem/m:Items/t:CalendarItem', namespaces=NAMESPACES)[0]

  if event.reminder_minutes_before_start:
    calendar_node.append(T.ReminderIsSet('true'))
    calendar_node.append(T.ReminderMinutesBeforeStart(str(event.reminder_minutes_before_start)))
  else:
    calendar_node.append(T.ReminderIsSet('false'))

  calendar_node.append(T.Start(start.strftime(EXCHANGE_DATETIME_FORMAT)))
  calendar_node.append(T.End(end.strftime(EXCHANGE_DATETIME_FORMAT)))

  if event.is_all_day:
    calendar_node.append(T.IsAllDayEvent('true'))

  calendar_node.append(T.Location(event.location or u''))

  if event.required_attendees:
    calendar_node.append(resource_node(element=T.RequiredAttendees(), resources=event.required_attendees))

  if event.optional_attendees:
    calendar_node.append(resource_node(element=T.OptionalAttendees(), resources=event.optional_attendees))

  if event.resources:
    calendar_node.append(resource_node(element=T.Resources(), resources=event.resources))

  if event.recurrence:

    if event.recurrence == u'daily':
      recurrence = T.DailyRecurrence(
        T.Interval(str(event.recurrence_interval)),
      )
    elif event.recurrence == u'weekly':
      recurrence = T.WeeklyRecurrence(
        T.Interval(str(event.recurrence_interval)),
        T.DaysOfWeek(event.recurrence_days),
      )
    elif event.recurrence == u'monthly':
      recurrence = T.AbsoluteMonthlyRecurrence(
        T.Interval(str(event.recurrence_interval)),
        T.DayOfMonth(str(event.start.day)),
      )
    elif event.recurrence == u'yearly':
      recurrence = T.AbsoluteYearlyRecurrence(
        T.DayOfMonth(str(event.start.day)),
        T.Month(event.start.strftime("%B")),
      )

    calendar_node.append(
      T.Recurrence(
        recurrence,
        T.EndDateRecurrence(
          T.StartDate(event.start.strftime(EXCHANGE_DATE_FORMAT)),
          T.EndDate(event.recurrence_end_date.strftime(EXCHANGE_DATE_FORMAT)),
        )
      )
    )

  return root