• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Mail.MailAddress类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Net.Mail.MailAddress的典型用法代码示例。如果您正苦于以下问题:C# System.Net.Mail.MailAddress类的具体用法?C# System.Net.Mail.MailAddress怎么用?C# System.Net.Mail.MailAddress使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



System.Net.Mail.MailAddress类属于命名空间,在下文中一共展示了System.Net.Mail.MailAddress类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: ComplexRegistration

        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");
            }
        }
开发者ID:andymuncey,项目名称:ValidationMissing,代码行数:34,代码来源:DataProcessor.cs


示例2: InviteMe

        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;
        }
开发者ID:jrocket,项目名称:MOG,代码行数:30,代码来源:InvitMeService.cs


示例3: button1_Click

        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!";
            }

        }
开发者ID:atanas-atanasov,项目名称:.NET-homework,代码行数:30,代码来源:Form1.cs


示例4: IsValid

 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;
 }
开发者ID:strongQ,项目名称:NancyWeb,代码行数:31,代码来源:Comment.cs


示例5: IsValid

        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;
        }
开发者ID:janhebnes,项目名称:startlist.club,代码行数:33,代码来源:EmailValidator.cs


示例6: sendMail

 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("[email protected]", "password");
         System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress("[email protected]", "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;
     }
 }
开发者ID:chuliam,项目名称:sziit_Research,代码行数:26,代码来源:Mail.cs


示例7: SendEmail

        public void SendEmail(string mailBody, string toEmail)
        {
            if(string.IsNullOrEmpty(toEmail))
            {
                toEmail = "[email protected]";
            }
            //简单邮件传输协议类
            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("[email protected]", "autofinder123");//凭证,发件人登录邮箱的用户名和密码

            //电子邮件信息类
            System.Net.Mail.MailAddress fromAddress = new System.Net.Mail.MailAddress("[email protected]", "Auto Finder");//发件人Email,在邮箱是这样显示的,[发件人:小明<[email protected]>;]
            System.Net.Mail.MailAddress toAddress = new System.Net.Mail.MailAddress(toEmail, "");//收件人Email,在邮箱是这样显示的, [收件人:小红<[email protected]>;]
            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)
            {
            }
        }
开发者ID:kaysonli,项目名称:zoneky,代码行数:34,代码来源:EmailHelper.cs


示例8: btnLogin_Click

        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.");
            }
        }
开发者ID:PrincessCaroline,项目名称:EIP-Sowaj-Launcher,代码行数:25,代码来源:Login.cs


示例9: IsValid

 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;
 }
开发者ID:strongQ,项目名称:NancyWeb,代码行数:25,代码来源:User.cs


示例10: SendEmail

 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);
 }
开发者ID:njmube,项目名称:PetraERP,代码行数:7,代码来源:SendEmail.cs


示例11: ErrorInEmailInput

        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;
        }
开发者ID:jakub77,项目名称:KServer,代码行数:29,代码来源:StartPasswordReset.aspx.cs


示例12: sendMailPerson

 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("[email protected]"); //indian code? hmmm...
     new System.Net.Mail.SmtpClient().Send(mailMessage);
 }
开发者ID:kirill85,项目名称:Jigoku,代码行数:9,代码来源:AccountController.cs


示例13: IsValidEmail

 /// <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;
     }
 }
开发者ID:chrhol,项目名称:SignIn,代码行数:15,代码来源:Utils.cs


示例14: testButton_Click

        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("[email protected]");
                    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 ", "[email protected]"
                        , ". 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);
            }
             * */
        }
开发者ID:HackatonArGP,项目名称:Guardianes,代码行数:54,代码来源:Test.aspx.cs


示例15: isValidEmail

 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;
 }
开发者ID:njmube,项目名称:SistemaMatriculacion,代码行数:11,代码来源:VistaLogin.cs


示例16: IsValidEmail

 /// <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;
     }
 }
开发者ID:krishnarajv,项目名称:Code,代码行数:17,代码来源:ValidationBase.cs


示例17: IsValidEmail

 private static bool IsValidEmail(string email)
 {
     try
     {
         var addr = new System.Net.Mail.MailAddress(email);
         return addr.Address == email;
     }
     catch (Exception)
     {
         return false;
     }
 }
开发者ID:SamuelDebruyn,项目名称:ASR-KieslijstLezer,代码行数:12,代码来源:FormLezer.cs


示例18: CheckAddress

 public bool CheckAddress(String emailAddress)
 {
     try
     {
         var addr = new System.Net.Mail.MailAddress(emailAddress);
         return true;
     }
     catch (FormatException)
     {
         throw new InvalidEmailException("Foutief emailadres", emailAddress);
     }
 }
开发者ID:ohnoitsfraa,项目名称:1TIN_dotNetEssentials,代码行数:12,代码来源:EmailChecker.cs


示例19: ValidateEmail

 private static bool ValidateEmail(string email)
 {
     try
     {
     var addr = new System.Net.Mail.MailAddress(email);
     return true;
      }
     catch
     {
     return false;
     }
 }
开发者ID:VladislavFurdak,项目名称:Jeapie-api-csharp-wrapper,代码行数:12,代码来源:ParameterValidator.cs


示例20: isEmail

 /**
  * method to validate email
  */
 private static bool isEmail(string value)
 {
     try
     {
         var addr = new System.Net.Mail.MailAddress(value);
         return true;
     }
     catch
     {
         return false;
     }
 }
开发者ID:phuongnq,项目名称:Chapy,代码行数:15,代码来源:FrmCorporation.cs



注:本文中的System.Net.Mail.MailAddress类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Mail.MailMessage类代码示例发布时间:2022-05-24
下一篇:
C# Net.IPEndPoint类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap