コード例 #1
0
        public void SendSelectedMails()
        {
            string from = CommonTools.Tools.ConfigEntry <string> .GetConfigEntry("SMTPSenderAdress", "*****@*****.**");

            string server = Session.SMTPServer;
            string user   = Session.UsernameSMTP;
            string pw     = Session.PasswordSMTP;


            foreach (var item in SelectedAdressen.Where(n => n.UnSelect != true))
            {
                try
                {
                    if (rbExchange == true)
                    {
                        if (AttachedFiles.Count() > 0)
                        {
                            SteinbachMail.TestMail.TestSendMail(server, user, pw, from, item.Mailadresse, MailSubject, MailBody, AttachedFiles.ToArray <string>(), SteinbachMail.TestMail.MessageType.Text);
                        }
                        else
                        {
                            SteinbachMail.TestMail.TestSendMail(server, user, pw, from, item.Mailadresse, MailSubject, MailBody, SteinbachMail.TestMail.MessageType.Text);
                            //SteinbachMail.TestMail.TestSendMail("mail.hostedoffice.ag", "*****@*****.**", "MnAbQHJ2010", "*****@*****.**", "*****@*****.**", MailSubject, MailBody);
                        }
                    }
                    else if (rbOutlook == true)
                    {
                        if (AttachedFiles.Count() > 0)
                        {
                            asOutlookMail.OutlookMail.sendmail(item.Mailadresse, MailSubject, MailBody, "", AttachedFiles.ToArray <string>(), asOutlookMail.MessageType.text);
                        }
                        else
                        {
                            asOutlookMail.OutlookMail.sendmail(item.Mailadresse, MailSubject, MailBody);
                        }
                    }


                    ThisDispatcher.BeginInvoke(new Action <Models.SelectedAdressesModel, bool>(SetisSent), item, true);
                    ThisDispatcher.BeginInvoke(new Action <Models.SelectedAdressesModel, string>(SetResult), item, "OK");
                }
                catch (Exception ex)
                {
                    // CommonTools.Tools.ErrorMethods.HandleStandardError(ex, item.Firmenname + ", " + item.Nachname + ", " + item.Vorname);
                    ThisDispatcher.BeginInvoke(new Action <Models.SelectedAdressesModel, string>(SetResult), item, ex.Message);
                    //item.Result = ex.Message;
                }
            }
        }
コード例 #2
0
        public void ExecuteAction()
        {
            switch (selectionType)
            {
            case SelectionType.Email:
            {
                var task1 = System.Threading.Tasks.Task.Factory.StartNew(() =>
                    {
                        ThisDispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, (new System.Action(() =>
                        {
                            SendSelectedMails();
                        })));
                    });



                break;
            }

            case SelectionType.Serienbrief:
            {
                InsertIntoTable();
                break;
            }

            case SelectionType.Adressetikett:
            {
                ShowSelectAdresses();
                break;
            }

            case SelectionType.None:
                break;

            default:
                break;
            }
        }