Example #1
0
        /// <summary>
        /// Serialization of the ETDDT class by using the properties path.
        /// </summary>
        /// <param name="etddt"> object ETDDT</param>
        public static void serialisieren(MailProperties mailProperties, string path)
        {
            XmlSerializer s = new XmlSerializer(typeof(MailProperties));
            TextWriter    w = new StreamWriter(path);

            s.Serialize(w, mailProperties);
            w.Close();
        }
        private void textBoxSender_TextChanged(object sender, EventArgs e)
        {
            TextBox tb = (TextBox)sender;

            if (MailProperties.IsMailAddress(tb.Text))
                tb.ForeColor = SystemColors.WindowText;
            else
                tb.ForeColor = Color.Red;
        }
Example #3
0
        public static bool Send(MailProperties mailProperties, String Subject, string Body, bool ErrorMessage)
        {
            // TODO fertig machen von zertificaTEN falls notig | wie sieht es mit mail empfangen aus?
            try
            {
                MailMessage mail = new MailMessage();

                SmtpClient SmtpServer = new SmtpClient(mailProperties.SMTPclient); //SMTP Server von Hotmail und Outlook.
                SmtpServer.Port      = mailProperties.SMTPclientPort;
                SmtpServer.EnableSsl = mailProperties.EnableSsl;

                mail.From = new MailAddress(mailProperties.SenderAddress); //Absender

                for (int i = 0; i < mailProperties.RecipientAdresses.Length; i++)
                {
                    mail.To.Add(mailProperties.RecipientAdresses[i]); //Empfänger
                }
                mail.Subject = Subject;

                mail.Body = Body;

                //mail.IsBodyHtml = true; //Nur wenn Body HTML Quellcode ist

                if (mailProperties.SenderUserName != null && mailProperties.SenderPassword != null)
                {
                    SmtpServer.Credentials = new System.Net.NetworkCredential(mailProperties.SenderUserName, MailProperties.SimpleEncode(mailProperties.SenderPassword));
                }

                // ServicePointManager.ServerCertificateValidationCallback =
                //     delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
                //     {
                //         return true;
                //     };

                SmtpServer.Send(mail);
                return(true);
            }
            catch (Exception ex)
            {
                if (ErrorMessage)
                {
                    MessageBox.Show("Error on sending Mail!" + Environment.NewLine + Environment.NewLine +
                                    "Sender:    " + mailProperties.SenderAddress + Environment.NewLine +
                                    "Subject:   " + Subject + Environment.NewLine +
                                    "Body:      " + Environment.NewLine +
                                    Body + Environment.NewLine + Environment.NewLine +
                                    "Error:     " + ex.Message, "Mail notification", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                return(false);
            }
        }
Example #4
0
        void textBox_TextChanged(object sender, EventArgs e)
        {
            if (suppress)
            {
                return;
            }
            TextBox tb = (TextBox)sender;

            if (!button[int.Parse(tb.Name)].Enabled)
            {
                int i = int.Parse(tb.Name);
                button[i].Enabled = true;
                i++;

                TextBox tbn = new TextBox()
                {
                    Name     = i.ToString(),
                    Size     = new Size(290, 20),
                    Location = new Point(3, i * 20 + 3),
                };

                tbn.TextChanged += new EventHandler(textBox_TextChanged);
                textBox.Add(tbn);

                Button btn = new Button()
                {
                    Name     = i.ToString(),
                    Text     = null,
                    Image    = global::eMail.Properties.Resources.erase,
                    Size     = new Size(20, 20),
                    Location = new Point(299, i * 20 + 3),
                    Enabled  = false,
                };
                btn.Click += new EventHandler(button_Click);
                button.Add(btn);

                panelRecipients.Controls.Add(tbn);
                panelRecipients.Controls.Add(btn);
            }

            if (MailProperties.IsMailAddress(tb.Text))
            {
                tb.ForeColor = SystemColors.WindowText;
            }
            else
            {
                tb.ForeColor = Color.Red;
            }
        }
Example #5
0
        public SimpleMailSend(MailProperties MailProperties, bool ReportErrors, string Subject = null, string Body = null)
        {
            this.MailProperties = MailProperties;
            this.ReportErrors   = ReportErrors;

            InitializeComponent();

            if (Subject != null)
            {
                this.Subject        = Subject;
                textBoxSubject.Text = Subject;
            }
            if (Body != null)
            {
                this.Body        = Body;
                textBoxBody.Text = Body;
            }
        }