|
-
Jun 2nd, 2006, 07:33 AM
#1
Thread Starter
Lively Member
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."
-
Jun 2nd, 2006, 07:51 AM
#2
Fanatic Member
Re: Regex and Email
hmm
one way of doing it is....
VB Code:
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}$")
If Not Regex.IsMatch(StringOfEmail) Then
Me.message.ForeColor = System.Drawing.Color.Red
Me.message.Text = "There is a problem with recipient: " & StringOfEmail
' bad email address
else
' good email address
End If
you may also want to take a quick peek at The Regular Expression Library Website
-
Jun 2nd, 2006, 07:54 AM
#3
Thread Starter
Lively Member
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."
-
Jun 2nd, 2006, 07:56 AM
#4
Fanatic Member
Re: Regex and Email
 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.
-
Jun 2nd, 2006, 08:00 AM
#5
Thread Starter
Lively Member
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."
-
Jun 2nd, 2006, 08:07 AM
#6
Fanatic Member
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?
-
Jun 2nd, 2006, 08:11 AM
#7
Thread Starter
Lively Member
"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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|