tags:

views:

556

answers:

2

hai guys, I have imported my gmail contacts from gmail and a file name called google.csv was download ... I want to read only the email ids in that file from asp.net... Please help me out guys....

+1  A: 

http://mail.google.com/support/bin/answer.py?hl=en&answer=12119
http://mail.google.com/support/bin/topic.py?hl=en&topic=12867

I'll re-articulate my answer if you re-articulate your question.

Dustin Getz
A: 

If I'm understanding you correctly, you want to read the CSV file that was exported from gmail and access the email records in a list. It's not difficult.

Put the csv file in your App_Data folder or wherever is convenient. Then parse the file, using a free CSV library like this one: http://www.codeproject.com/KB/database/CsvReader.aspx.

Or if you want a quick and dirty way, I noticed the google.csv has emails on the last column without quotes, so you could read the file in, split at commas, and look at the last item in the array... something like this:

List<string> emails = new List<string>();
string[] lines = File.ReadAllLines(Server.MapPath(filename));
//skip the first line
for(int x = 1; x < lines.Length; x++) {
  string[] fields = lines[x].Split(',');
  emails.Add(fields[fields.Length-1]);
}
chaiwalla