lib/ews/soap/exchange_data_services.rb
def create_item(opts)
      opts = opts.clone
      [:items].each do |k|
        validate_param(opts, k, true)
      end
      req = build_soap! do |type, builder|
        attribs = {}
        attribs['MessageDisposition'] = opts[:message_disposition] if opts[:message_disposition]
        attribs['SendMeetingInvitations'] = opts[:send_meeting_invitations] if opts[:send_meeting_invitations]
        if(type == :header)
        else
          builder.nbuild.CreateItem(attribs) {
            builder.nbuild.parent.default_namespace = @default_ns
            builder.saved_item_folder_id!(opts[:saved_item_folder_id]) if opts[:saved_item_folder_id]
            builder.nbuild.Items {
              opts[:items].each {|i|
                # The key can be any number of item types like :message,
                #   :calendar, etc
                ikey = i.keys.first
                builder.send("#{ikey}!",i[ikey])
              }
            }
          }
        end
      end
      do_soap_request(req, response_class: EwsResponse)
    end
def create_item(opts)
      opts = opts.clone
      [:items].each do |k|
        validate_param(opts, k, true)
      end
      req = build_soap! do |type, builder|
        attribs = {}
        attribs['MessageDisposition'] = opts[:message_disposition] if opts[:message_disposition]
        attribs['SendMeetingInvitations'] = opts[:send_meeting_invitations] if opts[:send_meeting_invitations]
        if(type == :header)
        else
          builder.nbuild.CreateItem(attribs) {
            builder.nbuild.parent.default_namespace = @default_ns
            builder.saved_item_folder_id!(opts[:saved_item_folder_id]) if opts[:saved_item_folder_id]
            builder.nbuild.Items {
              opts[:items].each {|i|
                # The key can be any number of item types like :message,
                #   :calendar, etc
                ikey = i.keys.first
                builder.send("#{ikey}!",i[ikey])
              }
            }
          }
        end
      end
      do_soap_request(req, response_class: EwsResponse)
    end
Defines a request to create an item in the Exchange store.
 @see http://msdn.microsoft.com/en-us/library/aa565209(v=EXCHG.140).aspx

 @param [Hash] opts
 @option opts [String] :message_disposition How the item will be handled after it is created.
   Only applicable for to e-mail. Must be one of 'SaveOnly', 'SendOnly', or 'SendAndSaveCopy'
 @option opts [String] :send_meeting_invitations How meeting requests are handled after they
   are created. Required for calendar items. Must be one of 'SendToNone', 'SendOnlyToAll',
   'SendToAllAndSaveCopy'
 @option opts [Hash] :saved_item_folder_id A well formatted folder_id Hash. Ex: {:id => :inbox}
   Will on work if 'SendOnly' is specified for :message_disposition
 @option opts [Array<Hash>] :items This is a complex Hash that conforms to various Item types.
   Please see the Microsoft documentation for this element.
 @example
   opts = {
     message_disposition: 'SendAndSaveCopy',
     items: [ {message:
       {subject: 'test2',
        body: {body_type: 'Text', text: 'this is a test'},
        to_recipients: [{mailbox: {email_address: 'dan.wanek@gmail.com'}}]
       }
     }]}

   opts = {
     send_meeting_invitations: 'SendToAllAndSaveCopy',
     items: [ {calendar_item:
       {subject: 'test cal item',
        body: {body_type: 'Text', text: 'this is a test cal item'},
        start: {text: Chronic.parse('tomorrow at 4pm').to_datetime.to_s},
        end: {text: Chronic.parse('tomorrow at 5pm').to_datetime.to_s},
        required_attendees: [
         {attendee: {mailbox: {email_address: 'dan.wanek@gmail.com'}}},
        ]
       }
     }]