Exemple #1
1
        /// <summary>
        /// Sends the HTML to the given email addresses.
        /// </summary>

        public void SendEmail(string[] toAddresses, string subject, string body, List<string> attachedFilePaths = null)
        {

            string fromAddress = emailSenderVisibleAddress;
            string fromName = emailSenderVisibleName;

            System.Net.Mail.MailMessage oMsg = new System.Net.Mail.MailMessage();

            System.Net.Mail.MailAddress addrFrom = new System.Net.Mail.MailAddress(fromAddress, fromName);
            oMsg.From = addrFrom;

            for (int i = 0; i <= toAddresses.Length - 1; i++)
            {
                System.Net.Mail.MailAddress address = new System.Net.Mail.MailAddress(toAddresses[i]);
                oMsg.To.Add(address);
            }

            oMsg.Subject = subject;

            oMsg.Body = body;

            //!!!
            oMsg.IsBodyHtml = true;

            if (attachedFilePaths != null)
            {
                foreach (string path in attachedFilePaths)
                {
                    System.Net.Mail.Attachment oAttch = new System.Net.Mail.Attachment(path);
                    oMsg.Attachments.Add(oAttch);
                }
            }

            //---
            //GENERIC:
            var client = new System.Net.Mail.SmtpClient(emailSenderHost, emailSenderPort);
            var myLogin = new System.Net.NetworkCredential(emailSenderUsername, emailSenderPassword);
            client.EnableSsl = false;

            client.EnableSsl = false;
            client.UseDefaultCredentials = true;
            client.Credentials = myLogin;
            client.EnableSsl = emailSenderEnableSsl;
            client.Send(oMsg);

        }
        private bool ErrorInEmailInput(string username, string email)
        {
            bool errorInForm = false;

            if (username.Length == 0)
            {
                UserNameErrorLabel.Text = "You must enter a username.";
                errorInForm = true;
            }

            if (email.Length == 0)
            {
                EmailErrorLabel.Text = "You must enter an email address.";
                errorInForm = true;
            }
            else
            {
                try
                {
                    var address = new System.Net.Mail.MailAddress(email);
                }
                catch
                {
                    EmailErrorLabel.Text = "That email address doesn't appear to be valid.";
                    errorInForm = true;
                }
            }
            return errorInForm;
        }
Exemple #3
0
 public bool IsValid()
 {
     if (String.IsNullOrWhiteSpace(Name)) return false;
     if (String.IsNullOrWhiteSpace(Email))
     {
         return false;
     }
     else
     {
         bool validAdress = true;
         try
         {
             var adress = new System.Net.Mail.MailAddress(Email).Address;
         }
         catch (FormatException)
         {
             validAdress = false;
         }
         if (!validAdress) return false;
     }
     if (String.IsNullOrWhiteSpace(Message))
     {
         return false;
     }
     else
     {
         Uri uri;
         if (System.Uri.TryCreate(Website, UriKind.Absolute, out uri)) return false;
     }
     return true;
 }
Exemple #4
0
 public bool sendMail(string toSb, string toSbName, string mailSub, string mailBody)
 {
     try
     {
         System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
         client.Host = "smtp.mxhichina.com";//smtp server
         client.Port = 25;
         client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
         client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "password");
         System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress("*****@*****.**", "systemName");
         System.Net.Mail.MailAddress toAddress = new System.Net.Mail.MailAddress(toSb, toSbName);
         System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(fromAddress, toAddress);
         mailMessage.Subject = mailSub;
         mailMessage.Body = mailBody;
         mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;
         mailMessage.BodyEncoding = System.Text.Encoding.UTF8;
         mailMessage.IsBodyHtml = true;
         mailMessage.Priority = System.Net.Mail.MailPriority.Normal; //级别
         client.Send(mailMessage);
         return true;
     }
     catch
     {
         return false;
     }
 }
        public static bool IsValid(string email, bool isExistingPilot)
        {
            var cleanEmail = ParseEmail(email);
            var valid = false;
            try
            {
                var addr = new System.Net.Mail.MailAddress(cleanEmail);
                if (addr.Address == cleanEmail)
                {
                    valid = true;
                }
            }
            catch
            {
                return false;
            }

            if (valid)
            {
                if (!isExistingPilot)
                {
                    return true;
                }
                else
                {
                    using (var shortDb = new FlightContext())
                    {
                        return shortDb.Pilots.Any(d => d.Email == cleanEmail);
                    }
                }
            }
            return false;
        }
Exemple #6
0
        public int InviteMe(string email, string ip)
        {
            try
            {
                var addr = new System.Net.Mail.MailAddress(email);

            }
            catch
            {
                return -1;
            }

            InviteMe test = this.repo.GetByEmail(email);
            if (test != null)
            {
                return test.Id;
            }

            InviteMe item = new InviteMe()
            {
                Email = email,
                Processed = false,
                Source = ip,
                CreatedOn = DateTime.Now
            };
            int createdId = this.repo.Create(item);
            this.serviceMail.SendAdminMail("New subscription : ", "whooot someone drop his/her email : " + email);

            return createdId;
        }
        public void ComplexRegistration(string user, string email, string password, string confirmPassword, string DOB)
        {
            //user name
            if (user.Length < 1) {
                throw new Exception("Invalid user name");
            }

            //password
            if (password.Length < 8)
            {
                throw new Exception("Password not secure - must be at least 8 characters");
            }

            if (password != confirmPassword)
            {
                throw new Exception("Mismatched password error");
            }

            //email
            System.Net.Mail.MailAddress add = new System.Net.Mail.MailAddress(email);

            //DOB
            var dateOfBirth = DateTime.Parse(DOB);

            if (dateOfBirth > DateTime.Now)
            {
                throw new Exception("Cannot be born in future");
            }

            if (DateTime.Now.AddYears(-120) > dateOfBirth)
            {
                throw new Exception("Cannot be that old");
            }
        }
        private void btnLogin_Click(object sender, EventArgs e)
        {
            RequestServer newreq = new RequestServer();
            ParserJSON parser = new ParserJSON();

            try
            {
                var addr = new System.Net.Mail.MailAddress(txtUsername.Text);
                s.tokenConnection = parser.ServerConnect(newreq.ServerConnect("", txtPassword.Text, txtUsername.Text));
            }
            catch
            {
                s.tokenConnection = parser.ServerConnect(newreq.ServerConnect(txtUsername.Text, txtPassword.Text, ""));
            }

            if (s.tokenConnection.connectionAccepted == true)
            {
                s.tokenConnection.Nickname = txtUsername.Text;
                s.AffProfil();
            }
            else
            {
                MessageBox.Show("Informations de connection incorrectes.");
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            label4.Text = String.Empty;
            try
            {


            var adress = new System.Net.Mail.MailAddress(textBox3.Text);
            StreamReader reader = new StreamReader("Entries.txt");
            string readFile = reader.ReadToEnd();
            reader.Close();
            if (readFile.Contains(textBox3.Text))
            {
                label4.Text = "Email is already in use!";
            }
            else
            {
                StreamWriter writer = new StreamWriter("Entries.txt", true);
                writer.WriteLine("{0}{1}{2}", textBox1.Text.PadRight(50, ' '), textBox2.Text.PadRight(50, ' '), textBox3.Text);
                writer.Close();
                label4.Text = "Registration successful!";
            }

            }
            catch (Exception)
            {
                label4.Text = "Invalid email!";
            }

        }
Exemple #10
0
        public void SendEmail(string mailBody, string toEmail)
        {
            if(string.IsNullOrEmpty(toEmail))
            {
                toEmail = "*****@*****.**";
            }
            //简单邮件传输协议类
            System.Net.Mail.SmtpClient client = new System.Net.Mail.SmtpClient();
            client.Host = "smtp.163.com";//邮件服务器
            client.Port = 25;//smtp主机上的端口号,默认是25.
            client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;//邮件发送方式:通过网络发送到SMTP服务器
            client.Credentials = new System.Net.NetworkCredential("*****@*****.**", "autofinder123");//凭证,发件人登录邮箱的用户名和密码

            //电子邮件信息类
            System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress("*****@*****.**", "Auto Finder");//发件人Email,在邮箱是这样显示的,[发件人:小明<*****@*****.**>;]
            System.Net.Mail.MailAddress toAddress = new System.Net.Mail.MailAddress(toEmail, "");//收件人Email,在邮箱是这样显示的, [收件人:小红<*****@*****.**>;]
            System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage(fromAddress, toAddress);//创建一个电子邮件类
            mailMessage.Subject = "From Auto Finder";

            mailMessage.Body = mailBody;//可为html格式文本
            //mailMessage.Body = "邮件的内容";//可为html格式文本
            mailMessage.SubjectEncoding = System.Text.Encoding.UTF8;//邮件主题编码
            mailMessage.BodyEncoding = System.Text.Encoding.UTF8;//邮件内容编码
            mailMessage.IsBodyHtml = false;//邮件内容是否为html格式
            mailMessage.Priority = System.Net.Mail.MailPriority.High;//邮件的优先级,有三个值:高(在邮件主题前有一个红色感叹号,表示紧急),低(在邮件主题前有一个蓝色向下箭头,表示缓慢),正常(无显示).
            try
            {
                client.Send(mailMessage);//发送邮件
                //client.SendAsync(mailMessage, "ojb");异步方法发送邮件,不会阻塞线程.
            }
            catch (Exception)
            {
            }
        }
Exemple #11
0
 static SendEmail()
 {
     string smpthost = Settings.GetSetting(Constants.SETTINGS_EMAIL_SMTP_HOST);
     string fromemail = Settings.GetSetting(Constants.SETTINGS_EMAIL_FROM);
     _smtp = new System.Net.Mail.SmtpClient(smpthost);
     _from = new System.Net.Mail.MailAddress(fromemail);
 }
Exemple #12
0
 public bool IsValid()
 {
     if (String.IsNullOrWhiteSpace(UserPassWord))
     {
         return false;
     }
     if (String.IsNullOrWhiteSpace(UserEmail))
     {
         return false;
     }
     else
     {
         bool validAddress = true;
         try
         {
             var address = new System.Net.Mail.MailAddress(UserEmail).Address;
         }
         catch (FormatException)
         {
             validAddress = false;
         }
         if (!validAddress) return false;
     }
     return true;
 }
Exemple #13
0
 private void sendMailPerson(Person person)
 {
     var mailMessage = new System.Net.Mail.MailMessage();
     var mailAddressTo = new System.Net.Mail.MailAddress(person.PrimaryMail);
     mailMessage.Subject = "No reply";
     mailMessage.Body = "Здравствуйте, дорогой (-ая) " + person.NickName + ", вы получили это письмо потому что зарегистрировались на портале Jigoku." + " Если вы не регистрировались у нас, игнорируйте это письмо.";
     mailMessage.Sender = new System.Net.Mail.MailAddress("*****@*****.**"); //indian code? hmmm...
     new System.Net.Mail.SmtpClient().Send(mailMessage);
 }
Exemple #14
0
 /// <summary>
 /// Check if Email has the correct syntax
 /// </summary>
 /// <param name="email"></param>
 /// <returns></returns>
 public static bool IsValidEmail(string email)
 {
     try {
         var addr = new System.Net.Mail.MailAddress(email);
         return addr.Address == email;
     }
     catch {
         return false;
     }
 }
 private bool isValidEmail(string email)
 {
     try
     {
         var addr = new System.Net.Mail.MailAddress(email);
         return addr.Address == email;
     }catch(Exception ex){
         MessageBox.Show("Email no valido");
     }
     return false;
 }
Exemple #16
0
        protected void testButton_Click(object sender, EventArgs e)
        {
            List<System.Net.Mail.MailMessage> messages = new List<System.Net.Mail.MailMessage>();
            for (int i = 0; i < 2; i++)
            {
                if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["smtp.enabled"]))
                {
                    System.Net.Mail.MailAddress address = new System.Net.Mail.MailAddress("*****@*****.**");
                    System.Net.Mail.MailAddress addressFrom = new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["smtp.user"], "Guardianes - Greenpeace");
                    System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage();
                    message.From = addressFrom;
                    message.To.Add(address);
                    message.Subject = "Te damos la bienvenida a Guardianes";

                    string domain = new Uri(HttpContext.Current.Request.Url.AbsoluteUri).GetLeftPart(UriPartial.Authority);

                    string htmlTemplate = System.IO.File.ReadAllText(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "mail.html"));
                    message.Body = string.Format(htmlTemplate, "Ya estás protegiendo los bósques de Salta!"
                        , @"Para Comenzar a jugar apretá el botón de abajo!
                                <br></br>

                                <b>Tips para Jugar</b>
                                <ul>
                                <li> Podés obtener una nueva parcela apretando [Cambiar Parcela]</li>
                                <li> Comentá en las parcelas de los demás para ayudarlos con sus reportes</li>
                                <li> Completá todos los tutoriales y jugá los minijuegos</li>
                                <li> Entrá varias veces al dia para obtener mas puntos</li>
                                </ul>"
                        , string.Format("{0}/index.html", domain), "Click acá para comenzar a cuidar el bósque", "Cuidar el Bosque", "Este mensaje se envío a ", "*****@*****.**"
                        , ". Si no quieres recibir más notificaciones en un futuro podés acceder al Panel de Control del usuario y deshabilitar la opción de recibir notificaciones."
                        , "Greenpeace Argentina. Todos los derechos reservados.", domain);
                    message.IsBodyHtml = true;
                    message.BodyEncoding = System.Text.Encoding.UTF8;
                    message.DeliveryNotificationOptions = System.Net.Mail.DeliveryNotificationOptions.None;
                    messages.Add(message);
                }
            }

            SendMails.Send(messages);

            this.hexCode.Text = "terminó";

            //var context = GlobalHost.ConnectionManager.GetHubContext<Hubs>();
            //context.Clients.All.LandChanged(hexCode.Text);
            /*
            Earthwatchers.Data.LandRepository repo = new Data.LandRepository(System.Configuration.ConfigurationManager.ConnectionStrings["EarthwatchersConnection"].ConnectionString);
            this.contentDiv.InnerHtml = string.Empty;
            foreach (var d in repo.MassiveReassign().OrderBy(x => x.Key))
            {
                //this.contentDiv.InnerHtml += d.Key.ToString() + "-" + d.Value + "<br>";
                this.contentDiv.InnerHtml += string.Format("'{0}',", d.Value);
            }
             * */
        }
 private static bool IsValidEmail(string email)
 {
     try
     {
         var addr = new System.Net.Mail.MailAddress(email);
         return addr.Address == email;
     }
     catch (Exception)
     {
         return false;
     }
 }
Exemple #18
0
 /// <summary>
 /// Check the string valid email..
 /// </summary>
 /// <param name="email"></param>
 /// <returns>true</returns>
 public bool IsValidEmail(string email)
 {
     try
     {
         var mail = new System.Net.Mail.MailAddress(email);
         return true;
     }
     catch
     {
         return false;
     }
 }
Exemple #19
0
 /**
  * method to validate email
  */
 private static bool isEmail(string value)
 {
     try
     {
         var addr = new System.Net.Mail.MailAddress(value);
         return true;
     }
     catch
     {
         return false;
     }
 }
 public bool CheckAddress(String emailAddress)
 {
     try
     {
         var addr = new System.Net.Mail.MailAddress(emailAddress);
         return true;
     }
     catch (FormatException)
     {
         throw new InvalidEmailException("Foutief emailadres", emailAddress);
     }
 }
 private static bool ValidateEmail(string email)
 {
     try
     {
     var addr = new System.Net.Mail.MailAddress(email);
     return true;
      }
     catch
     {
     return false;
     }
 }
Exemple #22
0
 public static bool IsValidEmail(this string input)
 {
     try
     {
         var addr = new System.Net.Mail.MailAddress(input);
         return addr.Address == input;
     }
     catch
     {
         return false;
     }
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static bool IsEmail(this string str)
        {
            try
            {
                var m = new System.Net.Mail.MailAddress(str);

                return true;
            }
            catch (FormatException)
            {
                return false;
            }
        }
Exemple #24
0
 private bool IsValidEmail(string email)
 {
     try
     {
         var addr = new System.Net.Mail.MailAddress(email);
         emailE.TextColor = Color.Default;
         return(true);
     }
     catch
     {
         emailE.TextColor = Color.Red;
         return(false);
     }
 }
Exemple #25
0
        private bool ValidateEmail()
        {
            try
            {
                var addr = new System.Net.Mail.MailAddress(txtCorreo.Text);

                return(addr.Address == txtCorreo.Text);
            } catch (Exception e)
            {
                MessageBox.Show("ERROR FATAL: " + e.Message);
            }

            return(false);
        }
Exemple #26
0
        bool IsValidEmail(string email)
        {
            try
            {
                var addr = new System.Net.Mail.MailAddress(email);
                return(true);
            }
            catch (Exception ex)
            {
                Response.Write(ex.InnerException);

                return(false);
            }
        }
Exemple #27
0
        public static void InvalidEmail(this IGuardClause guardClause, string email, string parameterName)
        {
            Guard.Against.NullOrWhiteSpace(email, nameof(email));

            try
            {
                var result = new System.Net.Mail.MailAddress(email);
                return;
            }
            catch (FormatException)
            {
                throw new ArgumentException($"Input {parameterName} was not a valid email.", parameterName);
            }
        }
Exemple #28
0
        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                if (textBox6.Text != "")
                {
                    object email = new System.Net.Mail.MailAddress(textBox6.Text);
                }
                if (maskedTextBox1.Text != "" &&
                    textBox2.Text != "" &&
                    textBox3.Text != "" &&
                    maskedTextBox2.Text != "" &&
                    !(!kontrol_veri_tekrari_yatirimci(maskedTextBox1.Text) || !kontrol_veri_tekrari_yatirimci(maskedTextBox4.Text)))
                {
                    baglan.Open();
                    string tedarikci_Guncelleme = "";
                    if (yapilacak_Islem == "Gercek_Kayit_Guncelle")
                    {
                        tedarikci_Guncelleme = "Update Yatirimci_Gercek_Kisi Set Yatırımcı_TC='" + maskedTextBox1.Text + "',Ad_Soyad='" + textBox3.Text + "',Telefon='" + maskedTextBox2.Text + "',Faks='" + maskedTextBox3.Text + "',E_posta='" + textBox6.Text + "',Yatırımcı_Adres='" + textBox2.Text + "' where Yatırımcı_TC='" + maskedTextBox1.Text + "'";
                    }
                    else
                    {
                        tedarikci_Guncelleme = "update Yatirimci_Tuzel_Kisi set Yatırımcı_TC='" + maskedTextBox1.Text + "',Ad_Soyad='" + textBox3.Text + "',Telefon='" + maskedTextBox2.Text + "',Faks='" + maskedTextBox3.Text + "',E_posta='" + textBox6.Text + "',Yatırımcı_Adres='" + textBox2.Text + "',Vergi_Dairesi='" + textBox5.Text + "',Vergi_No='" + maskedTextBox4.Text + "' where Yatırımcı_TC='" + maskedTextBox1.Text + "'";
                    }


                    SqlCommand cmd        = new SqlCommand(tedarikci_Guncelleme, baglan);
                    int        row_Update = cmd.ExecuteNonQuery();

                    if (row_Update > 0)
                    {
                        MessageBox.Show("Güncelleme Tamamlandı.", "Mesaj", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                }
                else
                {
                    MessageBox.Show("Zorunlu Alanları Doldurunuz.", "Form Eksik.", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }



                baglan.Close();
            }
            catch
            {
                MessageBox.Show("-Aynı TC No veya Vergi No İle Daha Önce Kayıt Yapılmış Olabilir.\n-Form Eksik Doldurulmuş Olabilir.", "Kayıt Başarısız", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            this.Close();
        }
        private void GenericTextBox_TextChanged(object sender, TextChangedEventArgs e)
        {
            if (id != -1)
            {
                //(sender as TextBox).SelectAll();
                //System.Diagnostics.Debug.WriteLine(txt.Name);
                //emailTextBox_TextChanged(sender, e);
                string nombre = ((sender as TextBox).Name).ToString();
                switch (nombre)
                {
                case "emailTextBox":
                    try
                    {
                        var addr = new System.Net.Mail.MailAddress(emailTextBox.Text);
                        if (addr.Address == emailTextBox.Text)
                        {
                            emailTextBox.ClearValue(TextBox.BackgroundProperty);
                            labelInfo.Content = labelInfo.Content.ToString().Replace("Error en el formato del email \r\n", "");
                        }
                    }
                    catch
                    {
                        emailTextBox.Background = (Brush) new BrushConverter().ConvertFrom("#FFBDAF");
                        labelInfo.Content      += "Error en el formato del email \r\n";
                    }
                    break;

                case "nifTextBox":
                    Regex regex  = new Regex("^[0-9]{8}[TtRrWwAaGgMmYyFfPpDdXxBbNnJjZzSsQqVvHhLlCcKkEe]$");
                    Regex regex2 = new Regex("^[TtRrWwAaGgMmYyFfPpDdXxBbNnJjZzSsQqVvHhLlCcKkEe][0-9]{8}$");
                    if (regex.IsMatch(nifTextBox.Text) || regex2.IsMatch(nifTextBox.Text))
                    {
                        nifTextBox.ClearValue(TextBox.BackgroundProperty);
                        labelInfo.Content = labelInfo.Content.ToString().Replace("Error en el formato del DNI \r\n", "");
                    }
                    else
                    {
                        nifTextBox.Background = (Brush) new BrushConverter().ConvertFrom("#FFBDAF");
                        labelInfo.Content    += "Error en el formato del DNI \r\n";
                    }
                    break;
                }
                CheckAceptar();
                //ClientesMain.AccesoVentana();
            }
            else if (id == -1)
            {
                FiltrarLista.DynamicInvoke();
            }
        }
Exemple #30
0
        public ActionResult ReciveSignedDoc(string data, string email)
        {
            var    addr          = new System.Net.Mail.MailAddress(email);
            string directorypath = Server.MapPath("~/App_Data/" + "Files/");

            if (!Directory.Exists(directorypath))
            {
                Directory.CreateDirectory(directorypath);
            }
            var serverpath = directorypath + addr.DisplayName.Trim() + ".pdf";

            System.IO.File.WriteAllBytes(serverpath, Convert.FromBase64String(data));
            return(View(serverpath));
        }
        private void txt_Email_Leave(object sender, EventArgs e)
        {
            string str = txt_Email.Text;

            try
            {
                var mail = new System.Net.Mail.MailAddress(str);
                errPro.Clear();
            }
            catch
            {
                errPro.SetError(txt_Email, "Invalid email !");
            }
        }
 private void txt_Emial_TextChanged(object sender, EventArgs e)
 {
     try
     {
         var eMailValidator = new System.Net.Mail.MailAddress(txt_Emial.Text);
         lab_emailStatus.Visible = false;
     }
     catch (FormatException ex)
     {
         lab_emailStatus.Visible = true;
         lab_emailStatus.Text    = "Invalid Email Address";
         // wrong e-mail address
     }
 }
Exemple #33
0
        public static string MaskEmail(this string userName)
        {
            try
            {
                var addr = new System.Net.Mail.MailAddress(userName);
                userName = userName.Substring(0, userName.IndexOf("@"));
            }
            catch
            {
                return(userName);
            }

            return(userName);
        }
        public void Send(string title, string url, string body)
        {
            var from = MailAddressUtilities.Get(Sessions.UserId(), withFullName: true);

            switch (Type)
            {
            case Types.Mail:
                if (Parameters.Notification.Mail)
                {
                    var mailFrom = new System.Net.Mail.MailAddress(
                        Addresses.BadAddress(from) == string.Empty
                                ? from
                                : Parameters.Mail.SupportFrom);
                    new OutgoingMailModel()
                    {
                        Title = new Title(Prefix + title),
                        Body  = "{0}\r\n{1}".Params(url, body) + (Addresses.FixedFrom(mailFrom)
                                ? "\r\n\r\n{0}<{1}>".Params(mailFrom.DisplayName, mailFrom.Address)
                                : string.Empty),
                        From = mailFrom,
                        To   = Address
                    }.Send();
                }
                break;

            case Types.Slack:
                if (Parameters.Notification.Slack)
                {
                    new Slack(
                        "*{0}{1}*\n{2}\n{3}".Params(Prefix, title, url, body),
                        from)
                    .Send(Address);
                }
                break;

            case Types.ChatWork:
                if (Parameters.Notification.ChatWork)
                {
                    new ChatWork(
                        "*{0}{1}*\n{2}\n{3}".Params(Prefix, title, url, body),
                        from,
                        Token)
                    .Send(Address);
                }
                break;

            default:
                break;
            }
        }
Exemple #35
0
        private void VerificationScoring(LandMini landMini)
        {
            if (landMini != null)
            {
                try
                {
                    //Mando los mails notificando
                    if (!string.IsNullOrEmpty(landMini.Email))
                    {
                        if (Convert.ToBoolean(System.Configuration.ConfigurationManager.AppSettings["smtp.enabled"]))
                        {
                            List <System.Net.Mail.MailMessage> messages = new List <System.Net.Mail.MailMessage>();

                            System.Net.Mail.MailAddress address     = new System.Net.Mail.MailAddress(landMini.Email);
                            System.Net.Mail.MailAddress addressFrom = new System.Net.Mail.MailAddress(System.Configuration.ConfigurationManager.AppSettings["smtp.user"], Labels.Labels.GuardiansGreenpeace);
                            System.Net.Mail.MailMessage message     = new System.Net.Mail.MailMessage();
                            message.From = addressFrom;
                            message.To.Add(address);
                            message.Subject = Labels.Labels.LandVerifications.ToString();

                            string domain = new Uri(HttpContext.Current.Request.Url.AbsoluteUri).GetLeftPart(UriPartial.Authority);

                            string htmlTemplate = System.IO.File.ReadAllText(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "mail.html"));
                            message.Body = string.Format(htmlTemplate, Labels.Labels.LandVerifications2
                                                         , Labels.Labels.LandVerifications3
                                                         , string.Format("{0}/index.html?geohexcode={1}", domain, landMini.GeohexKey), Labels.Labels.LandVerifications4, Labels.Labels.LandVerifications5, Labels.Labels.LandVerifications6, landMini.Email
                                                         , Labels.Labels.LandVerifications7
                                                         , Labels.Labels.LandVerifications8, domain);
                            message.IsBodyHtml   = true;
                            message.BodyEncoding = System.Text.Encoding.UTF8;
                            message.DeliveryNotificationOptions = System.Net.Mail.DeliveryNotificationOptions.None;
                            messages.Add(message);

                            SendMails.Send(messages);
                        }
                    }

                    //Genero la imagen de este land
                    ImagesGeneratorTool.Run(landRepository, true, landMini.GeohexKey);

                    //Notify the land owner if logged in
                    var context = GlobalHost.ConnectionManager.GetHubContext <Hubs>();
                    context.Clients.All.LandVerified(landMini.EarthwatcherId);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
        }
Exemple #36
0
 //checks that the string that the user entered in the email field is in email format
 private bool IsValidEmail(string email)
 {
     try
     {
         var addr = new System.Net.Mail.MailAddress(email);
         return(addr.Address == email);
     }
     catch (Exception ex)
     {
         FileLogger.WriteErrorToLog(ex + " in isValidEmailFunction");
         MessageBox.Show(ex.Message);
         return(false);
     }
 }
Exemple #37
0
        public void IsValidEmailTest()
        {
            string email = string.Empty;

            try
            {
                var addr = new System.Net.Mail.MailAddress(email);
            }
            catch (Exception ex)
            {
                throw new ApplicationException("Error code: " + ex.Message); //  return false;
            }
            Assert.Fail();
        }
Exemple #38
0
        // Check if is valid email
        private static string ValidateEmailField(string name, string value)
        {
            string msg = "";

            try {
                var  addr  = new System.Net.Mail.MailAddress(value);
                bool check = addr.Address == value;
            }
            catch {
                msg = string.Concat("The field: ", name, " with value: ", value, " is not valid email.");
            }

            return(msg);
        }
Exemple #39
0
 /// <summary>
 /// Validates email format
 /// </summary>
 /// <param name="email"></param>
 /// <returns></returns>
 public bool IsValidEmail(string email)
 {
     try
     {
         // Check for a valid email.
         var valid = new System.Net.Mail.MailAddress(email);
         return(true);
     }
     catch (Exception)
     {
         // Invalid email
         return(false);
     }
 }
        private void SaveBtn_Click(object sender, EventArgs e)
        {
            int value    = 0;
            int semester = 0;

            if (CourseCmb.SelectedValue.ToString() != null & SemesterCmb.SelectedItem != null)
            {
                value    = int.Parse(CourseCmb.SelectedValue.ToString());
                semester = int.Parse(SemesterCmb.SelectedItem.ToString());
            }
            if (EmailTxt.Text != "")
            {
                try
                {
                    var eMailValidator = new System.Net.Mail.MailAddress(EmailTxt.Text);
                    var result         = FormOperations.ValidateFields(NameTxt.Text, SurnameTxt.Text, GenderCmb.SelectedItem, CellNTxt.Text, value, semester);
                    if (result)
                    {
                        FormOperations.student.Name          = NameTxt.Text;
                        FormOperations.student.Surname       = SurnameTxt.Text;
                        FormOperations.student.Gender        = GenderCmb.SelectedItem.ToString();
                        FormOperations.student.Cell          = CellNTxt.Text;
                        FormOperations.student.Email         = EmailTxt.Text;
                        FormOperations.student.PostalAddress = Postaltxt.Text;
                        FormOperations.student.Semester      = semester;
                        FormOperations.student.CourseId      = value;
                        //FormOperations.student.StatusId = int.Parse(StatusCmb.SelectedValue.ToString());

                        FormOperations.student.ID = DataAccess.InsertStudent(FormOperations.student);

                        MessageBox.Show("Student Saved Successfully. Please Proceesd to Gaurdian Information", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        FormOperations.OpenGaurdian();
                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("Please Fill In All Fields", "Empty field Found", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    }
                }
                catch (FormatException ex)
                {
                    MessageBox.Show("The Email entered is not a valid email address", "Invalid Email", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }
            else
            {
                MessageBox.Show("Please fill in all fields", "Empty Fields Detected", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemple #41
0
 /// <summary>
 /// Vérifie si la chaine de caracteres spécifiée est au format email
 /// </summary>
 /// <param name="string2Verify">Chaine de caractères à vérifier</param>
 /// <returns>Booléen determinant si la chaine est au format email ou non</returns>
 public static bool IsMailFormat(string string2Verify)
 {
     try
     {
         System.Net.Mail.MailAddress test = new System.Net.Mail.MailAddress(string2Verify);
         return(Regex.IsMatch(string2Verify,
                              @"^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))" +
                              @"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$"));
     }
     catch
     {
         return(false);
     }
 }
        /// <summary>
        /// Check the email has valid or not
        /// </summary>
        /// <param name="value">The value</param>
        /// <returns>returns bool value</returns>
        public bool Check(T value)
        {
            try
            {
                var addr = new System.Net.Mail.MailAddress($"{value}");
                return(addr.Address == $"{value}");
            }
            catch
            {
                return(false);

                throw;
            }
        }
Exemple #43
0
        public override bool IsSatisfiedBy(OrderRequest order, ref ICollection <string> errors)
        {
            try
            {
                var senderEmail = new System.Net.Mail.MailAddress(order.SenderEmail);

                return(senderEmail.Address == order.SenderEmail);
            }
            catch
            {
                errors.Add("Invalid Sender email address");
                return(false);
            }
        }
        public override bool IsValid(object value)
        {
            string email = value.ToString();

            try
            {
                var addr = new System.Net.Mail.MailAddress(email);
                return(addr.Address == email);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemple #45
0
        public void IsValid()
        {
            const string ValidAddressString = "*****@*****.**";

            Assert.IsTrue(Utilities.Net.Mail.MailAddress.IsValid(ValidAddressString));

            var validMailAddress = new System.Net.Mail.MailAddress(ValidAddressString);

            Assert.IsTrue(Utilities.Net.Mail.MailAddress.IsValid(validMailAddress));

            const string InvalidAddressString = "ipsum lorem";

            Assert.IsFalse(Utilities.Net.Mail.MailAddress.IsValid(InvalidAddressString));
        }
Exemple #46
0
        public virtual System.Web.Mvc.ActionResult Edit(Models.NewsComments newsComments)
        {
            newsComments.UpdateDateTime = Infrastructure.Utility.Now;

            if (ModelState.IsValid)
            {
                UnitOfWork.NewsCommentsRepository.Update(newsComments);

                UnitOfWork.Save();
                if (newsComments.IsActive)
                {
                    try
                    {
                        System.Net.Mail.MailMessage msg  = new System.Net.Mail.MailMessage();
                        System.Net.Mail.MailAddress from = new System.Net.Mail.MailAddress("*****@*****.**", "وب سایت رسمی ناصر فروتن", System.Text.Encoding.UTF8);
                        System.Net.Mail.MailAddress to   = new System.Net.Mail.MailAddress(newsComments.Email, "وب سایت رسمی ناصر فروتن", System.Text.Encoding.UTF8);

                        msg.Subject         = "تائید نظر شما";
                        msg.SubjectEncoding = System.Text.Encoding.UTF8;
                        msg.Body            = "کابر گرامی" + " " + newsComments.Username + " " + "با تشکر از  شما ، نظر شما در سایت قرار گرفت" + "\n\r" +
                                              "وب سایت رسمی داور بین المللی کشتی ناصر فروتن";
                        msg.BodyEncoding = System.Text.Encoding.UTF8;
                        msg.From         = from;
                        msg.To.Add(to);


                        System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
                        //  smtp.Host = "smtp.mail.yahoo.com";
                        //  "mail.pap-ict.ir";
                        smtp.Host        = "smtp.gmail.com";
                        smtp.Port        = 587;
                        smtp.Timeout     = 36000;
                        smtp.EnableSsl   = true;
                        smtp.Credentials = new NetworkCredential("*****@*****.**", "naserforoutan1397");
                        smtp.Send(msg);
                    }
                    catch (System.Exception)
                    {
                        return(RedirectToAction(MVC.NewsComments.Index()));
                    }
                }
                return(RedirectToAction(MVC.NewsComments.Index()));
            }

            ViewBag.NewsId =
                new System.Web.Mvc.SelectList
                    (UnitOfWork.NewsRepository.Get(), "Id", "Title", newsComments.NewsId);

            return(View(newsComments));
        }
Exemple #47
0
 public static void IsValid(string emailValue)
 {
     if (!string.IsNullOrEmpty(emailValue))
     {
         try
         {
             var addr = new System.Net.Mail.MailAddress(emailValue);
         }
         catch
         {
             throw new ArgumentException(EXCEPTION_MESSAGE_EMAIL_IS_NOT_VALID);
         }
     }
 }
        private void MailTextBox_MouseLeave(object sender, EventArgs e)
        {
            TextBox txt = (TextBox)sender;

            try
            {
                var mail = new System.Net.Mail.MailAddress(txt.Text);
                err.Clear();
            }
            catch
            {
                this.err.SetError(txt, "Not Format Email ");
            }
        }
 bool esCorreo(string correo)
 {
     try
     {
         var mail = new System.Net.Mail.MailAddress(correo);
         return(true);
     }
     catch (Exception ex)
     {
         string metodoYclase = this.GetType().Name + ", " + System.Reflection.MethodBase.GetCurrentMethod().Name;
         registrarError(ex, metodoYclase);
         return(false);
     }
 }
Exemple #50
0
        private bool validateEmail(string Value)
        {
            if (Value == null)
            {
                return(false);
            }

            try {
                var addr = new System.Net.Mail.MailAddress(Value);
                return(addr.Address == Value);
            } catch {
                return(false);
            }
        }
Exemple #51
0
 public static bool IsValidEmailAddress(string email)
 {
     try
     {
         //ข้อยกเว้นเฉพาะ ให้มี .@ ในที่อยู่อีเมล์ได้
         string email2 = email.Replace(".@", "@");
         var    addr   = new System.Net.Mail.MailAddress(email2);
         return(addr.Address == email2);
     }
     catch
     {
         return(false);
     }
 }
 private bool IsValidEmail(string Email)
 {
     try
     {
         var addr = new System.Net.Mail.MailAddress(Email);
         EmailEmpty = "Transparent";
         return(addr.Address == email);
     }
     catch
     {
         EmailEmpty = "Red";
         return(false);
     }
 }
Exemple #53
0
        public static bool IsValidEmail(TextBox textToBeVerified)
        {
            string stringToBeVerified = textToBeVerified.Text.Trim();

            try
            {
                var addr = new System.Net.Mail.MailAddress(stringToBeVerified);
                return(!(addr.Address == stringToBeVerified));
            }
            catch
            {
                return(true);
            }
        }
 public override bool PassesValidation(string input, out string details)
 {
     System.Net.Mail.MailAddress throwaway;
     details = null;
     try
     {
         throwaway = new System.Net.Mail.MailAddress(input, String.Empty);
         return true;
     }
     catch
     {
         details = String.Format("Value was: '{0}'", input);
         return false;
     }
 }
Exemple #55
0
 public bool IsEmailAddress()
 {
     bool isEmail = false;
     try
     {
         if (this.CellValue == Constants.DEFAULT_STRING) return isEmail; //false
         System.Net.Mail.MailAddress address = new System.Net.Mail.MailAddress(this.CellValue);
         isEmail = true;
     }
     catch (FormatException)
     {
         // Do nothing
     }
     return isEmail;
 }
        public void InternationalEmailAddress_can_be_cast_from_a_regular_framework_email_address()
        {
            //// Arrange

            var sut = new System.Net.Mail.MailAddress("*****@*****.**", "Firstname Lastname");

            //// Act

            var actual = (InternationalEmailAddress) sut;

            //// Assert

            actual.HostnamePartAsIdn.Should().Be("example.org");
            actual.User.Should().Be("test");
        }
Exemple #57
0
        public static MailingList LoadFromCSV(TextReader source)
        {
            var adapter = new CSVAdapter();
            adapter.Load(source, ',');

            if (adapter.Rows.Count < 1)
                throw new FormatException("La mailing list è priva di righe");
            if (adapter.RowLength != 6)
                throw new FormatException("Il numero di campi nel CSV Non è corretto: " + adapter.RowLength);

            var usersData = adapter.Rows
                .Select(x => new
                {
                    Utenza = x[0],
                    Gruppo = x[1],
                    Ruolo = x[2],
                    Nome = x[3],
                    Cognome = x[4],
                    Mail = x[5],
                });

            var dictionary = new Dictionary<string, IUser>(adapter.Rows.Count);
            foreach (var tupla in usersData)
            {
                try
                {
                    var mail = new System.Net.Mail.MailAddress(tupla.Mail);

                    //i named parameters sono una feature di C# 4.0 (Visual Studio 2010+)
                    dictionary.Add(tupla.Utenza,
                        new User(
                            /*utenza : */tupla.Utenza,
                            /*gruppo : */tupla.Gruppo,
                            /*ruolo : */tupla.Ruolo,
                            /*nome : */tupla.Nome,
                            /*cognome : */tupla.Cognome,
                            /*mail : */mail
                        )
                    );
                }
                catch(Exception e)
                {
                    throw new FormatException("Errore nella conversione della riga.\r\nVedere l'eccezione interna per ulteriori dettagli.", e);
                }
            }

            return new MailingList(dictionary);
        }
Exemple #58
0
        public override bool IsValid(object value)
        {
            var str = value.ToString();
            bool bln;
            try
            {
                System.Net.Mail.MailAddress mail = new System.Net.Mail.MailAddress(str);
                bln = true;
            }
            catch
            {
                bln = false;
            }

            return bln;
        }
Exemple #59
0
        public static bool EmailAddress(string address)
        {
            // Simple email address validation: http://stackoverflow.com/a/1374644
            try
            {
                var addressCheck = new System.Net.Mail.MailAddress(address);
                if (!addressCheck.Address.Equals(address))
                    return false;
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }
        public bool IsValidEmailAddress()
        {
            if (Email.Length < 3)
                return false;

            try
            {
                // ReSharper disable once UnusedVariable
                var addr = new System.Net.Mail.MailAddress(Email);
            }
            catch(FormatException)
            {
                return false;
            }
            return true;
        }