def new_event(event):
id = T.DistinguishedFolderId(Id=event.calendar_id) if event.calendar_id in DISTINGUISHED_IDS else T.FolderId(Id=event.calendar_id)<EOL>start = convert_datetime_to_utc(event.start)<EOL>end = convert_datetime_to_utc(event.end)<EOL>root = M.CreateItem(<EOL>M.SavedItemFolderId(id),<EOL>M.Items(<EOL>T.CalendarItem(<EOL>T.Subject(event.subject),<EOL>T.Body(event.body or u'<STR_LIT>', BodyType="<STR_LIT>"),<EOL>)<EOL>),<EOL>SendMeetingInvitations="<STR_LIT>"<EOL>)<EOL>calendar_node = root.xpath(u'<STR_LIT>', namespaces=NAMESPACES)[<NUM_LIT:0>]<EOL>if event.reminder_minutes_before_start:<EOL><INDENT>calendar_node.append(T.ReminderIsSet('<STR_LIT:true>'))<EOL>calendar_node.append(T.ReminderMinutesBeforeStart(str(event.reminder_minutes_before_start)))<EOL><DEDENT>else:<EOL><INDENT>calendar_node.append(T.ReminderIsSet('<STR_LIT:false>'))<EOL><DEDENT>calendar_node.append(T.Start(start.strftime(EXCHANGE_DATETIME_FORMAT)))<EOL>calendar_node.append(T.End(end.strftime(EXCHANGE_DATETIME_FORMAT)))<EOL>if event.is_all_day:<EOL><INDENT>calendar_node.append(T.IsAllDayEvent('<STR_LIT:true>'))<EOL><DEDENT>calendar_node.append(T.Location(event.location or u'<STR_LIT>'))<EOL>if event.required_attendees:<EOL><INDENT>calendar_node.append(resource_node(element=T.RequiredAttendees(), resources=event.required_attendees))<EOL><DEDENT>if event.optional_attendees:<EOL><INDENT>calendar_node.append(resource_node(element=T.OptionalAttendees(), resources=event.optional_attendees))<EOL><DEDENT>if event.resources:<EOL><INDENT>calendar_node.append(resource_node(element=T.Resources(), resources=event.resources))<EOL><DEDENT>if event.recurrence:<EOL><INDENT>if event.recurrence == u'<STR_LIT>':<EOL><INDENT>recurrence = T.DailyRecurrence(<EOL>T.Interval(str(event.recurrence_interval)),<EOL>)<EOL><DEDENT>elif event.recurrence == u'<STR_LIT>':<EOL><INDENT>recurrence = T.WeeklyRecurrence(<EOL>T.Interval(str(event.recurrence_interval)),<EOL>T.DaysOfWeek(event.recurrence_days),<EOL>)<EOL><DEDENT>elif event.recurrence == u'<STR_LIT>':<EOL><INDENT>recurrence = T.AbsoluteMonthlyRecurrence(<EOL>T.Interval(str(event.recurrence_interval)),<EOL>T.DayOfMonth(str(event.start.day)),<EOL>)<EOL><DEDENT>elif event.recurrence == u'<STR_LIT>':<EOL><INDENT>recurrence = T.AbsoluteYearlyRecurrence(<EOL>T.DayOfMonth(str(event.start.day)),<EOL>T.Month(event.start.strftime("<STR_LIT>")),<EOL>)<EOL><DEDENT>calendar_node.append(<EOL>T.Recurrence(<EOL>recurrence,<EOL>T.EndDateRecurrence(<EOL>T.StartDate(event.start.strftime(EXCHANGE_DATE_FORMAT)),<EOL>T.EndDate(event.recurrence_end_date.strftime(EXCHANGE_DATE_FORMAT)),<EOL>)<EOL>)<EOL>)<EOL><DEDENT>return root<EOL>
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>