Beispiel #1
0
        async void PopulateEmailLists(int UserId)
        {
            EmailListManagement cm         = new EmailListManagement(UserId);
            List <EmailList>    emailLists = cm.GetAllLists();
            List <EmlList>      emlLists   = new List <EmlList>();

            foreach (EmailList emailList in emailLists)
            {
                EmlList eml = new EmlList
                {
                    List_Name = emailList.List_Name,
                    List_Dtls = emailList.List_Dtls,
                    Emlist_Id = emailList.Emlist_Id,
                    U_Id      = emailList.U_Id
                };
                if (emailList.Eml_Id.Contains(","))
                {
                    eml.TotalMails = emailList.Eml_Id.Split(',').Length;
                }
                else if (emailList.Eml_Id.Length == 2)
                {
                    eml.TotalMails = 1;
                }
                emlLists.Add(eml);
            }
            await Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => dgv.ItemsSource = emlLists));
        }
Beispiel #2
0
 private void Page_Loaded(object sender, RoutedEventArgs e)
 {
     if (emaillistid != 0)
     {
         EmailListManagement emallistManagement = new EmailListManagement(UserId, EmailListId: emaillistid);
         EmailList           emaillist          = emallistManagement.GetList();
         ListNameTb.Text      = emaillist.List_Name;
         ListDtlsTb.Text      = emaillist.List_Dtls;
         EMailIdstb.Text      = emaillist.Eml_Id;
         DeleteBtn.Visibility = Visibility.Visible;
     }
 }
Beispiel #3
0
        private void DeleteBtn_MouseDown(object sender, MouseButtonEventArgs e)
        {
            MessageBoxResult messageBoxResult = MessageBox.Show("Are you sure you want to delete the campaign?", "Confirmation", System.Windows.MessageBoxButton.YesNo);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                EmailListManagement emailListManagement = new EmailListManagement(UserId, EmailListId: emaillistid);
                emailListManagement.Delete();
                Window home      = Window.GetWindow(this);
                Frame  MainFrame = FindChild <Frame>(home, "MainFrame");
                MainFrame.Navigate(new EmailListPage()
                {
                    UserId = UserId
                });
            }
            else
            {
            }
        }
Beispiel #4
0
        private void AddCampBtn_MouseDown(object sender, MouseButtonEventArgs e)
        {
            Random rand = new Random();

            if (emaillistid == 0)
            {
                emaillistid = rand.Next(100, 999);
            }
            EmailListManagement emailListManagement = new EmailListManagement(UserId, EMailIdstb.Text, emaillistid, ListNameTb.Text, ListDtlsTb.Text);

            emailListManagement.ProecessSuccess += Success;
            emailListManagement.ProcessFail     += Failed;
            if (AddListBtn.DisplayText != "Update")
            {
                emailListManagement.Add();
            }
            else
            {
                emailListManagement.Update();
            }
        }
Beispiel #5
0
        public RunCampaign(int UserId, int CampaignID, int EmailListId)
        {
            CampaignManagement campaignmanagement = new CampaignManagement(UserId, DateTime.Now, CampaignId: CampaignID);
            Campaign           campaign           = campaignmanagement.GetCampaign();
            UserManagement     userManagement     = new UserManagement(UserId);
            User user = userManagement.GetUserById();

            string[] emailListIds = new string[] { campaign.Emlist_Id };
            if (campaignmanagement.emaillistid.Contains(','))
            {
                emailListIds = campaignmanagement.emaillistid.Split(',').ToArray();
            }
            if (!CampaignCompleted(campaign))
            {
                Parallel.For(0, emailListIds.Length, index =>
                {
                    int listId = Convert.ToInt32(emailListIds[index]);
                    EmailListManagement emailListManagement = new EmailListManagement(UserId, EmailListId: listId);
                    Email[] emails    = emailListManagement.GetAllEmailsFromList();
                    UserAuth auth     = new UserAuth();
                    SmtpClient client = auth.Authenticate();
                    var message       = new MimeMessage();
                    List <MailboxAddress> recepients = new List <MailboxAddress>();
                    for (int i = 0; i < emails.Length; i++)
                    {
                        message.To.Add(new MailboxAddress(emails[i].F_Name, emails[i].Email_Add));
                    }
                    message.From.Add(new MailboxAddress("Arrivarn", campaign.Sender_Email));
                    message.Subject = campaign.Eml_Subject;
                    var bodyBuilder = new BodyBuilder
                    {
                        HtmlBody = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "\\Emails\\" + campaign.Tmp_Id + "XX" + campaign.Tmp_Name)
                    };
                    message.Body = bodyBuilder.ToMessageBody();
                    client.Send(message);
                    client.Disconnect(true);
                });
            }
            ;
        }