Any email validation functions?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • VB Programmer

    Any email validation functions?

    Does anyone have any VB.NET functions which validate an email address?
    Could you post it? I would like it to do as much as the regular expression
    validator if possible.

    Thanks in advance!


  • Brian Henry

    #2
    Re: Any email validation functions?

    there should already be a email validator regex function in the validators
    to test for this (at least there is in asp.net) but here you go...

    \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*

    regex function to validate all email addresses

    "VB Programmer" <Dont*NoSpam-Please*@jEmail. com> wrote in message
    news:uurcDSqoEH A.2636@TK2MSFTN GP09.phx.gbl...[color=blue]
    > Does anyone have any VB.NET functions which validate an email address?
    > Could you post it? I would like it to do as much as the regular
    > expression
    > validator if possible.
    >
    > Thanks in advance!
    >
    >[/color]


    Comment

    • VB Programmer

      #3
      Re: Any email validation functions?

      Thanks, but I'm looking for a VB.NET version. Do you know of one?

      "Brian Henry" <brianiupmsdn@n ewsgroups.nospa m> wrote in message
      news:exT$dVqoEH A.536@TK2MSFTNG P11.phx.gbl...[color=blue]
      > there should already be a email validator regex function in the validators
      > to test for this (at least there is in asp.net) but here you go...
      >
      > \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
      >
      > regex function to validate all email addresses
      >
      > "VB Programmer" <Dont*NoSpam-Please*@jEmail. com> wrote in message
      > news:uurcDSqoEH A.2636@TK2MSFTN GP09.phx.gbl...[color=green]
      > > Does anyone have any VB.NET functions which validate an email address?
      > > Could you post it? I would like it to do as much as the regular
      > > expression
      > > validator if possible.
      > >
      > > Thanks in advance!
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • VB Programmer

        #4
        Re: Any email validation functions?

        Oh... I got it! Here's one I'd like to share. If anyone has any better one
        please let me know.

        Private Function EmailIsValid(By Val strEmailAddress As String) As
        Boolean
        Return Regex.IsMatch(s trEmailAddress,
        "^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9
        \-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")
        End Function

        Thanks!


        "VB Programmer" <Dont*NoSpam-Please*@jEmail. com> wrote in message
        news:%234QS8dqo EHA.3668@TK2MSF TNGP15.phx.gbl. ..[color=blue]
        > Thanks, but I'm looking for a VB.NET version. Do you know of one?
        >
        > "Brian Henry" <brianiupmsdn@n ewsgroups.nospa m> wrote in message
        > news:exT$dVqoEH A.536@TK2MSFTNG P11.phx.gbl...[color=green]
        > > there should already be a email validator regex function in the[/color][/color]
        validators[color=blue][color=green]
        > > to test for this (at least there is in asp.net) but here you go...
        > >
        > > \w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
        > >
        > > regex function to validate all email addresses
        > >
        > > "VB Programmer" <Dont*NoSpam-Please*@jEmail. com> wrote in message
        > > news:uurcDSqoEH A.2636@TK2MSFTN GP09.phx.gbl...[color=darkred]
        > > > Does anyone have any VB.NET functions which validate an email address?
        > > > Could you post it? I would like it to do as much as the regular
        > > > expression
        > > > validator if possible.
        > > >
        > > > Thanks in advance!
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Jos

          #5
          Re: Any email validation functions?

          VB Programmer wrote:[color=blue]
          > Oh... I got it! Here's one I'd like to share. If anyone has any
          > better one please let me know.
          >
          > Private Function EmailIsValid(By Val strEmailAddress As String) As
          > Boolean
          > Return Regex.IsMatch(s trEmailAddress,
          >[/color]
          "^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9[color=blue]
          > \-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")
          > End Function[/color]

          Unfortunately, this code will refuse mails from the "museum" domain.

          Replace the {2,4} with {2,6} to allow for this domain as well.

          --

          Jos


          Comment

          • VB Programmer

            #6
            Re: Any email validation functions?

            Thanks! Great catch!

            "Jos" <josnospambrand ers@fastmail.fm > wrote in message
            news:%23vvL2Ito EHA.1992@TK2MSF TNGP09.phx.gbl. ..[color=blue]
            > VB Programmer wrote:[color=green]
            > > Oh... I got it! Here's one I'd like to share. If anyone has any
            > > better one please let me know.
            > >
            > > Private Function EmailIsValid(By Val strEmailAddress As String) As
            > > Boolean
            > > Return Regex.IsMatch(s trEmailAddress,
            > >[/color]
            >[/color]
            "^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9[color=blue][color=green]
            > > \-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")
            > > End Function[/color]
            >
            > Unfortunately, this code will refuse mails from the "museum" domain.
            >
            > Replace the {2,4} with {2,6} to allow for this domain as well.
            >
            > --
            >
            > Jos
            >
            >[/color]


            Comment

            • Jay B. Harlow [MVP - Outlook]

              #7
              Re: Any email validation functions?

              In addition to the other comments:

              MSDN has a handful of common Regular Expressions
              patterns.

              Here is the e-mail example:


              The same section has a number of other examples.


              I also find these pages to be useful when dealing with Regular Expressions:
              At Regular-Expressions.info you will find a wide range of in-depth information about a powerful search pattern language called regular expressions.




              Hope this helps
              Jay

              "VB Programmer" <Dont*NoSpam-Please*@jEmail. com> wrote in message
              news:uurcDSqoEH A.2636@TK2MSFTN GP09.phx.gbl...[color=blue]
              > Does anyone have any VB.NET functions which validate an email address?
              > Could you post it? I would like it to do as much as the regular
              > expression
              > validator if possible.
              >
              > Thanks in advance!
              >
              >[/color]


              Comment

              • Vince

                #8
                Re: Any email validation functions?

                I don't get anything of what is happening in the function!!! How does this
                validate Email addresses and why not the museum domain??
                Confused & (probably) stupid.

                "VB Programmer" <Dont*NoSpam-Please*@jEmail. com> wrote in message
                news:evRX4h0oEH A.3520@TK2MSFTN GP11.phx.gbl...[color=blue]
                > Thanks! Great catch!
                >
                > "Jos" <josnospambrand ers@fastmail.fm > wrote in message
                > news:%23vvL2Ito EHA.1992@TK2MSF TNGP09.phx.gbl. ..[color=green]
                > > VB Programmer wrote:[color=darkred]
                > > > Oh... I got it! Here's one I'd like to share. If anyone has any
                > > > better one please let me know.
                > > >
                > > > Private Function EmailIsValid(By Val strEmailAddress As String) As
                > > > Boolean
                > > > Return Regex.IsMatch(s trEmailAddress,
                > > >[/color]
                > >[/color]
                >[/color]
                "^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9[color=blue][color=green][color=darkred]
                > > > \-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")
                > > > End Function[/color]
                > >
                > > Unfortunately, this code will refuse mails from the "museum" domain.
                > >
                > > Replace the {2,4} with {2,6} to allow for this domain as well.
                > >
                > > --
                > >
                > > Jos
                > >
                > >[/color]
                >
                >[/color]


                Comment

                • Vince

                  #9
                  Re: Any email validation functions?

                  Never mind, just saw Jay's post.
                  "Vince" <sdsad@fsd.co m> wrote in message
                  news:ulzrCEDpEH A.648@tk2msftng p13.phx.gbl...[color=blue]
                  > I don't get anything of what is happening in the function!!! How does this
                  > validate Email addresses and why not the museum domain??
                  > Confused & (probably) stupid.
                  >
                  > "VB Programmer" <Dont*NoSpam-Please*@jEmail. com> wrote in message
                  > news:evRX4h0oEH A.3520@TK2MSFTN GP11.phx.gbl...[color=green]
                  > > Thanks! Great catch!
                  > >
                  > > "Jos" <josnospambrand ers@fastmail.fm > wrote in message
                  > > news:%23vvL2Ito EHA.1992@TK2MSF TNGP09.phx.gbl. ..[color=darkred]
                  > > > VB Programmer wrote:
                  > > > > Oh... I got it! Here's one I'd like to share. If anyone has any
                  > > > > better one please let me know.
                  > > > >
                  > > > > Private Function EmailIsValid(By Val strEmailAddress As String)[/color][/color][/color]
                  As[color=blue][color=green][color=darkred]
                  > > > > Boolean
                  > > > > Return Regex.IsMatch(s trEmailAddress,
                  > > > >
                  > > >[/color]
                  > >[/color]
                  >[/color]
                  "^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9[color=blue][color=green][color=darkred]
                  > > > > \-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$")
                  > > > > End Function
                  > > >
                  > > > Unfortunately, this code will refuse mails from the "museum" domain.
                  > > >
                  > > > Replace the {2,4} with {2,6} to allow for this domain as well.
                  > > >
                  > > > --
                  > > >
                  > > > Jos
                  > > >
                  > > >[/color]
                  > >
                  > >[/color]
                  >
                  >[/color]


                  Comment

                  Working...