Click here to Skip to main content
15,894,017 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi friends........


I have one question and I dont have any idea how to solve that question.

My question is......

In my database,I have valid email id and invalid email id.
How to fetch valid email id from database using C#
Posted
Comments
ridoy 13-Apr-13 2:17am    
I think you need regular expression to check that validation.Try with that expression what OriginalGriff stated below.

Try this next time:

Click me![^]
 
Share this answer
 
Comments
1989priya 12-Apr-13 14:09pm    
hi richcb

I am not getting what did you send to me
Richard C Bishop 12-Apr-13 14:12pm    
Where is says "Clicke me!", click there and that will help you solve your issue.
You can't tell if an email address read from your database is valid or not except by first looking at it and seeing if it conforms to the rules for emails addresses[^] and then sending it an email and seeing if you get a response.

Even a "good looking" email address (in the sense that it is well formed and conforms to the rules for such addresses) such as xxx@xxx.xxx can be sent to, but it is not a "valid" email address in that there is either a message box at the other end, or a human being to read it if there was. The only way to tell is to send an email and see if you get a response - if you do, it is a valid email address at that moment.

That does not mean it is a valid email address immediately after you have received the response - there are places which provide valid email addresses which last a total of ten minutes for example.
 
Share this answer
 
Comments
1989priya 12-Apr-13 14:22pm    
hi OriginalGriff

I am not getting propery what to you want to say?
OriginalGriff 12-Apr-13 14:28pm    
What part do you have difficulty with? Or what part do you understand?
1989priya 12-Apr-13 14:34pm    
my ques is that how to show valid email id in textbox or gridview
OriginalGriff 12-Apr-13 14:37pm    
So I assume all the email addresses in your DB are "valid"?
How are you accessing them at the moment, and how you you know which one to display?
1989priya 12-Apr-13 14:43pm    
no,my ques is I have some email id like a@g.com and some invalid in like a@@a@.com,
I wanna do that when I fetch email id from database.At that time only valid email should be fetch
Dear by the following method you can get your work done

1. Read all email-ID in a datatable

2. use the following method to check ifthe email is valid

C#
//suppose datatable name is dt

if(dt.Rows[0]["Email"].toString().indexOf("@")>0) 
{

string emailPart=dt.Rows[0]["Email"].toString().SubString(dt.Rows[0]["Email"].toString().indexOf("@"),dt.Rows[0]["Email"].toString().Length-dt.Rows[0]["Email"].toString().indexOf("@"));

if(emailPart.IndexOf(".")>0)
{

//display the email in your textBox
}
}


I guess it solves your problem. Do let me know if it dosen't
 
Share this answer
 
v2
Comments
1989priya 15-Apr-13 6:26am    
hi Raj Parashar

It does not work

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900