// Sitecore.Modules.EmailCampaign.Core.RecipientImporter
        public override string PerformImport(ImportOptions options)
        {
            Assert.ArgumentNotNull(options, "options");
              int num = 0;
              int num2 = 0;
              int num3 = 0;
              int num4 = 0;
              string result;

              string emailReport = Sitecore.Configuration.Settings.GetSetting("RecipientImporterExt.PathToEmailReport", "/temp")
            + "/ProblemRecordsFor_" + Path.GetFileNameWithoutExtension(options.Filename)
            + "_" + DateTime.Now.ToString("s").Replace(":", string.Empty) + ".csv";

              string pathToEmailReport = FileUtil.MapPath(emailReport);
              StreamWriter streamWriter = new StreamWriter(pathToEmailReport);

              using (CsvFile csvFile = new CsvFile(options.Filename))
              {
            try
            {
              List<string> list = csvFile.ReadLine();
              streamWriter.WriteLine(string.Join(",", list.ToArray()));
              int emailColumnIndex = this.GetEmailColumnIndex(options, list);
              if (emailColumnIndex < 0)
              {
            result = string.Empty;
            return result;
              }
              List<string> list2 = csvFile.ReadLine();
              List<List<string>> listOfEntries = new List<List<string>>();

              while (list2 != null)
              {
              listOfEntries.Add(list2);
              csvFile.ReadLine();
              }

              Parallel.ForEach<List<string>>(listOfEntries, item => Process(item, streamWriter));
              while (list2 != null)
              {

              }
            }
            catch (Exception e)
            {
              Logging.LogError(e);
            }
            finally
            {
              streamWriter.Close();
            }
              }
              result = string.Concat(new object[]
            {
            num,  "|",
            num2, "|",
            num3, "|",
            num4
            });

              try
              {
            Sitecore.Data.Database master = Sitecore.Configuration.Factory.GetDatabase("master");
            Sitecore.Data.Items.Item itemToSend = master.GetItem(Sitecore.Configuration.Settings.GetSetting("RecipientImporterExt.MessagePath", "/sitecore/content/Home/Email Campaign/Messages/Service Messages/Self-Service Subscription/Subscription Notification"));
            MessageItem messageItem = Sitecore.Modules.EmailCampaign.Factory.GetMessage(itemToSend);
            //var report = new MediaItem();
            //messageItem.Attachments.Add(
            messageItem.Body = string.Format("Recipients imported: {0} <br/> E-mail addresses already exist: {1} <br/> E-mail addresses not provided: {2} <br/> Users not imported as required fields not available: {3}"
                                        + " <br/> You can check report file with the failed records here: {4}. <br/> Import finished at " + DateTime.Now.ToString(@"d/M/yyyy hh:mm:ss tt"), num, num2, num3, num4, pathToEmailReport);
            messageItem.Subject = "User import from "+Path.GetFileNameWithoutExtension(options.Filename)+" finished." ;
            SendingManager sendingManager = new SendingManager(messageItem);

            ListString usernamesToSend = new ListString(Sitecore.Configuration.Settings.GetSetting("RecipientImporterExt.SendTo", "sitecore\\admin"), ',');
            if (usernamesToSend.Count == 0)
            {
            Log.Info("RecipientImporterExt debug info: no users to send email to ", this);
            return result;
            }
            foreach (string nameString in usernamesToSend)
            {
            Contact contactToSend = Sitecore.Modules.EmailCampaign.Factory.GetContactFromName(nameString);
            if (contactToSend != null)
            {
                Log.Info("RecipientImporterExt debug info: Sending notification about the import to " + contactToSend.Profile.Email, this);
                sendingManager.SendStandardMessage(contactToSend);
            }
            }

            //User user = Sitecore.Context.User;
            //if (user != null)
            //{
            //    string username = user.Name;
            //    Log.Info("------------contactToSend2: " + username, this);
            //    sendingManager.SendStandardMessage(Sitecore.Modules.EmailCampaign.Factory.GetContactFromName(username));
            //}
              }
              catch (Exception e)
              {

            Logging.LogError(e);
              }

              return result;
        }
        private void NotifyUsers(ImportOptions options, int num, int num2, int num3, int num4, string pathToEmailReport)
        {
            try
            {
            Sitecore.Data.Database master = Sitecore.Modules.EmailCampaign.Util.GetContentDb();

            MediaCreatorOptions md = new MediaCreatorOptions();

            md.Destination = @"/sitecore/media library/Files/" + Sitecore.Configuration.Settings.GetSetting("RecipientImporterExt.PathToEmailReport", "/temp")+"/" + Path.GetFileNameWithoutExtension(pathToEmailReport);    // Set options
            md.Database = master;   // Set options
            MediaItem mediaItem = null;
            using (new SecurityDisabler())   // Use the SecurityDisabler object to override the security settings
            {
                // Create Media in database from file
                mediaItem = MediaManager.Creator.CreateFromFile(pathToEmailReport, md);
            }

            Sitecore.Data.Items.Item itemToSend = master.GetItem(Sitecore.Configuration.Settings.GetSetting("RecipientImporterExt.MessagePath", "/sitecore/content/Home/Email Campaign/Messages/Service Messages/Self-Service Subscription/Subscription Notification"));
            MessageItem messageItem = Sitecore.Modules.EmailCampaign.Factory.GetMessage(itemToSend);

            messageItem.Body = string.Format("Recipients imported: {0} <br/> E-mail addresses already exist: {1} <br/> E-mail addresses not provided: {2} <br/> Users not imported as required fields not available: {3}"
                                            + " <br/> You can check report file with the failed records here: {4}. <br/> Import finished at " + DateTime.Now.ToString(@"d/M/yyyy hh:mm:ss tt"), num, num2, num3, num4, pathToEmailReport);
            messageItem.Subject = "User import from " + Path.GetFileNameWithoutExtension(options.Filename) + " finished.";
            if (mediaItem != null)
            {
                messageItem.Attachments.Add(mediaItem);
            }
            SendingManager sendingManager = new SendingManager(messageItem);

            ListString usernamesToSend = new ListString(Sitecore.Configuration.Settings.GetSetting("RecipientImporterExt.SendTo", "sitecore\\admin"), ',');
            if (usernamesToSend.Count == 0)
            {
                Log.Info("RecipientImporterExt debug info: no users configured to send email to. Email will be sent only to the context user.", this);
                //  return result;
            }
            else
            {
                foreach (string nameString in usernamesToSend)
                {
                    Contact contactToSend = Sitecore.Modules.EmailCampaign.Factory.GetContactFromName(nameString);
                    if (contactToSend != null)
                    {
                        Log.Info("RecipientImporterExt debug info: Sending notification about the import to " + contactToSend.Profile.Email, this);
                        sendingManager.SendStandardMessage(contactToSend);
                    }
                }
            }

            User user = Sitecore.Context.User;
            if (user != null && !usernamesToSend.Contains(user.Name))
            {
                string username = user.Name;
                Contact contactToSend = Sitecore.Modules.EmailCampaign.Factory.GetContactFromName(username);
                if (contactToSend != null)
                {
                    Log.Info("RecipientImporterExt debug info: Sending notification about the import to " + username, this);
                    sendingManager.SendStandardMessage(contactToSend);
                }
            }
            }
            catch (Exception e)
            {

            Logging.LogError(e);
            }
        }