Results 1 to 7 of 7

Thread: Regex and Email

  1. #1

    Thread Starter
    Lively Member safewithyou247's Avatar
    Join Date
    Dec 2005
    Posts
    64

    Regex and Email

    So I need to create code that will read an emil and compare lines against regex and if the lines match then parse them into a variable. I think I have the regex part down. The only problem is I cannot figure out how to read the email.

    Can someone help?
    "A candle loses nothing by lighting another candle."

  2. #2
    Fanatic Member TokersBall_CDXX's Avatar
    Join Date
    Mar 2003
    Location
    America
    Posts
    571

    Re: Regex and Email

    hmm
    one way of doing it is....
    VB Code:
    1. Dim Regex As New System.Text.RegularExpressions.Regex("^(([A-Za-z0-9]+_+)|([A-Za-z0-9]+\-+)|([A-Za-z0-9]+\.+)|([A-Za-z0-9]+\++))*[A-Za-z0-9]+@((\w+\-+)|(\w+\.))*\w{1,63}\.[a-zA-Z]{2,6}$")
    2. If Not Regex.IsMatch(StringOfEmail) Then
    3.  Me.message.ForeColor = System.Drawing.Color.Red
    4.  Me.message.Text = "There is a problem with recipient: " & StringOfEmail
    5.  ' bad email address
    6. else
    7.  ' good email address
    8. End If

    you may also want to take a quick peek at The Regular Expression Library Website
    Build your own personalized flash based chat room for your webpage for FREE! http://www.4computerheaven.com

  3. #3

    Thread Starter
    Lively Member safewithyou247's Avatar
    Join Date
    Dec 2005
    Posts
    64

    Re: Regex and Email

    But how do I get the email into strings to compare against the regex?
    "A candle loses nothing by lighting another candle."

  4. #4
    Fanatic Member TokersBall_CDXX's Avatar
    Join Date
    Mar 2003
    Location
    America
    Posts
    571

    Re: Regex and Email

    Quote Originally Posted by safewithyou247
    But how do I get the email into strings to compare against the regex?
    that would depend greatly on your UI... how are you taking input of the email addresses? does the user provide them.. or do you have a list to check? a database?

    where are the email addresses being provided from.
    Build your own personalized flash based chat room for your webpage for FREE! http://www.4computerheaven.com

  5. #5

    Thread Starter
    Lively Member safewithyou247's Avatar
    Join Date
    Dec 2005
    Posts
    64

    Re: Regex and Email

    For the time being the email is just on the local computer that I am running the code. Eventually it will be in a database which I will implement in due time. So I have the file saved locally in .msg format.
    "A candle loses nothing by lighting another candle."

  6. #6
    Fanatic Member TokersBall_CDXX's Avatar
    Join Date
    Mar 2003
    Location
    America
    Posts
    571

    Re: Regex and Email

    ahh I see, so you're trying to actually read a saved email message saved locally on your system... then parse data from it?
    Build your own personalized flash based chat room for your webpage for FREE! http://www.4computerheaven.com

  7. #7

    Thread Starter
    Lively Member safewithyou247's Avatar
    Join Date
    Dec 2005
    Posts
    64

    Re: Regex and Email

    thats it.
    "A candle loses nothing by lighting another candle."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width