#include <stdio.h>
String GetEmail(String FileName)
{
FILE *in, *in1;
char readchar;
char readchar1;
String EMailAddr="";
String StrEMailAddr="";
if ((in = fopen(FileName.c_str(), "rb"))== NULL)
return "";
if ((in1 = fopen(FileName.c_str(), "rb"))== NULL)
return "";
fseek(in, 0L, SEEK_END);
int length= ftell(in);
fseek(in, 0L, SEEK_SET);
fseek(in1, 0L, SEEK_SET);
for( int i=0;i<length;i++)
{
fread(&readchar,sizeof(readchar),1,in);
if(readchar=='@')
{
fseek(in1, i-1, SEEK_SET);
fread(&readchar1,sizeof(readchar1),1,in1);
int j=2;
while((readchar1>='0'&&readchar1<='9')||(readchar1>='a'&&readchar1<='z')||(readchar1>='A'&&readchar1<='Z')||readchar1=='_'||readchar1=='.')
{
if((i-j)<=0)
break;
fseek(in1, i-j, SEEK_SET);
j++;
fread(&readchar1,sizeof(readchar1),1,in1);
}
if(j>3)
{
fread(&readchar1,sizeof(readchar1),1,in1);
while((readchar1>='0'&&readchar1<='9')||(readchar1>='a'&&readchar1<='z')||(readchar1>='A'&&readchar1<='Z')||readchar1=='_'||readchar1=='.'||readchar1=='@')
{
if((readchar1>='0'&&readchar1<='9')||(readchar1>='a'&&readchar1<='z')||(readchar1>='A'&&readchar1<='Z')||readchar1=='_'||readchar1=='.'||readchar1=='@')
EMailAddr+=AnsiString(readchar1);
fread(&readchar1,sizeof(readchar1),1,in1);
}
if(EMailAddr.Length()>7&&EMailAddr[EMailAddr.Length()]!='@'&&EMailAddr[EMailAddr.Length()]!='.')
StrEMailAddr+=","+ EMailAddr;
EMailAddr="";
}
}
}
fclose(in);
fclose(in1);
return StrEMailAddr;
}