title: Import Accounts and Contacts Zip File via the Dynamics CRM SDK
body: <p>I need to automate the Dynamics CRM Import Wizard that currently lets you zip up Accounts and Contacts files together and import them into CRM all at once as per the screen shot below.</p>
  
  <p><a href="https://i.stack.imgur.com/cNJFA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cNJFA.png" alt="enter image description here"></a></p>
  
  <p>We have quite a few zip files to import so thought it might be wise to automate this using the Dynamics CRM SDK. Looking in the SDK I can find an example of importing entity files 1 by 1 such as <a href="https://msdn.microsoft.com/en-us/library/hh547396.aspx" rel="nofollow noreferrer">here</a> but no examples of importing them together in a zip file? Is this possible and if so are there any examples of this? For instance the SDK code below looks at an "Import Accounts.csv" file only but I really need something to handle an "Import Accounts and Contacts.zip".</p>
  
  <pre><code>// Create Import File.
  ImportFile importFile = new ImportFile()
  {
      Content = BulkImportHelper.ReadCsvFile("Import Accounts.csv"), // Read contents from disk.
      Name = "Account record import",
      IsFirstRowHeader = true,
      ImportMapId = new EntityReference(ImportMap.EntityLogicalName, importMapId),
      UseSystemMap = false,
      Source = "Import Accounts.csv",
      SourceEntityName = "Account_1",
      TargetEntityName = Account.EntityLogicalName,
      ImportId = new EntityReference(Import.EntityLogicalName, importId),
      EnableDuplicateDetection = false,
      FieldDelimiterCode =
          new OptionSetValue((int)ImportFileFieldDelimiterCode.Comma),
      DataDelimiterCode =
          new OptionSetValue((int)ImportFileDataDelimiterCode.DoubleQuote),
      ProcessCode =
          new OptionSetValue((int)ImportFileProcessCode.Process)
  };
  </code></pre>