public bool ImportContacts() { this.names = new ArrayList(); this.emails = new ArrayList(); addressBookURL=domain+".indiatimes.com/service/home/~/Contacts?auth=co&fmt=csv"; try { htmlResponse = httpUtils.GetHttpResponse(this.addressBookURL,false); System.IO.MemoryStream strm = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(htmlResponse)); System.IO.StreamReader str = new System.IO.StreamReader(strm); int count=0,counter; addresses b=new addresses(); String temp_name="",temp_email=""; CSVReader csv = new CSVReader(str); string[] fields; string[] temp_line; while ((fields = csv.GetCSVLine()) != null) { temp_line=new string[100]; if(count!=0) { counter=0; foreach (string field in fields) { temp_line[counter]=field; counter++; } if(fields.Length==5) { temp_name=temp_line[2]+" "+temp_line[3]; temp_email=temp_line[0]; } else { temp_name=(temp_line[5]+" "+temp_line[10]+" "+temp_line[9]); temp_email=(temp_line[1]!="") ? temp_line[1]:(((temp_line[2]!="")? temp_line[2]:((temp_line[3]!="") ? temp_line[3]:""))); } if(temp_email!=null && temp_name==null) { temp_name=temp_email.Substring(0,temp_email.IndexOf("@")); } if(temp_email!=null && temp_name!=null) { names.Add(temp_name); emails.Add(temp_email); } } count++; } if(names.Count>0) { return true; } else { return false; } } catch(WebException ex) { Logout(); return false; } }
public addressesEnumerator(addresses addresses) { this.addresses = addresses; }
public bool ImportContacts() { names = new ArrayList(); emails = new ArrayList(); String tmpName = ""; String tmpEmail = ""; int count=0,counter; addresses b=new addresses(); addressBookURL = "https://www.plaxo.com/export"; String exportUrl = "https://www.plaxo.com/export/plaxo_ab_yahoo.csv"; try { htmlResponse = httpUtils.GetHttpResponse(addressBookURL,false); this.strFrm = htmlResponse.Substring(htmlResponse.IndexOf("<form")); this.strFrm = this.strFrm.Substring(0,this.strFrm.IndexOf("</form>")); this.strHidden = StringUtils.HiddenFields(this.strFrm); postString = strHidden+"&paths.0.checked=on&type=Y&x=36&y=19"; reffer = addressBookURL; htmlResponse = httpUtils.GetHttpResponse(exportUrl,false,postString,reffer); System.IO.MemoryStream strm = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(htmlResponse)); System.IO.StreamReader str = new System.IO.StreamReader(strm); CSVReader csv = new CSVReader(str); string[] fields; string[] temp_line; while ((fields = csv.GetCSVLine()) != null) { if(fields.Length < 5) continue; temp_line=new string[1024]; if(count!=0) { counter=0; foreach (string field in fields) { temp_line[counter]=field; counter++; } tmpName=(temp_line[0]=="") ? temp_line[1]:temp_line[0]; tmpName=(temp_line[0]=="" && temp_line[1]=="") ? temp_line[2]:((temp_line[2]!="" && temp_line[0]!="") ? temp_line[0]+" "+temp_line[1]+" "+temp_line[2]:tmpName) ; tmpEmail = (temp_line[3]=="") ? temp_line[4]:temp_line[3]; if(StringUtils.IsValidEmail(tmpEmail) && tmpName=="") { tmpName=tmpEmail.Substring(0,tmpEmail.IndexOf("@")); } if(StringUtils.IsValidEmail(tmpEmail)) { names.Add(tmpName); emails.Add(tmpEmail); } } count++; } if(names.Count>0) { return true; } else { return false; } } catch(Exception e) { Dispose(); return false; } }
public bool ImportContacts() { this.names = new ArrayList(); this.emails = new ArrayList(); try { addressBookURL="http://ksiazka-adresowa.wp.pl/import-export.html"; htmlResponse=httpUtils.GetHttpResponse(addressBookURL,false); String post="gr_id=0&program=yh&x=29&y=3"; String exportUrl="http://ksiazka-adresowa.wp.pl/csv.html"; String addressresponse=httpUtils.GetHttpResponse(exportUrl,false,post,addressBookURL,""); System.IO.MemoryStream strm = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(addressresponse)); System.IO.StreamReader str = new System.IO.StreamReader(strm); int count=0,counter; addresses b=new addresses(); String temp_name="",temp_email=""; CSVReader csv = new CSVReader(str); string[] fields; string[] temp_line; while ((fields = csv.GetCSVLine()) != null) { temp_line=new string[100]; if(count!=0) { counter=0; foreach (string field in fields) { temp_line[counter]=field; counter++; } temp_name=(temp_line[0]+" "+temp_line[1]+" "+temp_line[4]); temp_email=(temp_line[2]!="") ? temp_line[2]:(((temp_line[22]!="")? temp_line[22]:"")); if(temp_email!=null && temp_name==null) { temp_name=temp_email.Substring(0,temp_email.IndexOf("@")); } if(temp_email!=null && temp_name!=null) { names.Add(temp_name); emails.Add(temp_email); } } count++; } if(names.Count>0) { return true; } else { return false; } } catch(WebException ex) { Logout(); return false; } }
public bool ImportContacts() { String adrUrl,htmlResponse; names = new ArrayList(); emails = new ArrayList(); adrUrl = "http://mail01.mail.com/scripts/addr/addressbook.cgi?showaddressbook=1"; htmlResponse = httpUtils.GetHttpResponse(adrUrl,false); String tempStr="<a href=\"http://mail01.mail.com/scripts/addr/external.cgi?.ob="; String ob=""; if(htmlResponse.IndexOf(tempStr)!=-1) { ob=htmlResponse.Substring(htmlResponse.IndexOf(tempStr)+tempStr.Length); ob=ob.Substring(0,ob.IndexOf("&gab")); } String exportUrl="http://mail01.mail.com/scripts/addr/external.cgi?.ob="+ob+"&gab=1"; String postStrig="showexport=showexport&action=export&format=csv"; htmlResponse=httpUtils.GetHttpResponse(exportUrl,false,postStrig,""); System.IO.MemoryStream strm = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(htmlResponse)); System.IO.StreamReader str = new System.IO.StreamReader(strm); int count=0,counter; addresses b=new addresses(); string temp_name="",temp_email=""; CSVReader csv = new CSVReader(str); string[] fields; string[] temp_line; while ((fields = csv.GetCSVLine()) != null) { temp_line=new string[100]; if(count!=0) { counter=0; foreach (string field in fields) { temp_line[counter]=field; counter++; } temp_name=(temp_line[2]=="") ? temp_line[0]:temp_line[2]; temp_name=(temp_line[2]=="" && temp_line[0]=="") ? temp_line[3]:((temp_line[2]!="" && temp_line[0]!="") ? temp_line[2]+", "+temp_line[0]+" "+temp_line[1]:temp_name) ; temp_email=(temp_line[4]!="") ? temp_line[4]:(((temp_line[12]!="")? temp_line[12]:((temp_line[13]!="") ? temp_line[13]:""))); if(StringUtils.IsValidEmail(temp_email) && temp_name=="") { temp_name=temp_email.Substring(0,temp_email.IndexOf("@")); } if(StringUtils.IsValidEmail(temp_email)) { names.Add(temp_name); emails.Add(temp_email); } } count++; } if(names.Count>0) { return true; } else { return false; } }
//Parse yahoo csv address file private void yahoo_parser(StreamReader str) { int count=0,counter,ncount=0; addresses b=new addresses(); string temp_name="",temp_email=""; CSVReader csv = new CSVReader(str); string[] fields; string[] temp_line; while ((fields = csv.GetCSVLine()) != null) { temp_line=new string[100]; if(count!=0) { counter=0; foreach (string field in fields) { temp_line[counter]=field; counter++; } temp_name=(temp_line[2]=="") ? temp_line[0]:temp_line[2]; temp_name=(temp_line[2]=="" && temp_line[0]=="") ? temp_line[7]:((temp_line[2]!="" && temp_line[0]!="") ? temp_line[2]+", "+temp_line[0]+" "+temp_line[1]:temp_name) ; temp_email=(temp_line[4]!="") ? temp_line[4]:temp_line[7]+"@yahoo.com"; try { if(temp_email.IndexOf(':')!=-1) temp_email=temp_email.Substring(temp_email.IndexOf(':')+1); } catch {} if(temp_email!=null && temp_email!="@yahoo.com") b.Add(temp_name+"<html></tr></html>"+temp_email); else ncount++; } count++; } count=count-ncount; this.emailArray=new string[count-1]; this.nameArray=new string[count-1]; count=0; Regex r=new Regex(@"\s*<html></tr></html>\s*"); string[] addressD; foreach(string s in b) { addressD=r.Split(s); nameArray[count]=addressD[0]; emailArray[count]=addressD[1]; count++; } }