Well then there's probably something wrong with the code that checks for duplicate emails, since the first email was correctly identified.
It compiles then reads the file and says there is only 1 email but there is really 40.
This line in the for loop is useless, since any emails that have been added are already lowercased:
transform(b.begin(), b.end(), b.begin(), toLower());
Opening the file "" will likely fail, and so your code there would never get a chance to execute. I'd put it first and put the ordinary opening code in an else clause.
if(!fin.good()) throw "I/O error";
That probably doesn't sdo what you want, as s is always equal to i-2 and e to i+2.
anEmail = line.substr(s, (e - s) + 1);
You probably meant to put this code in a loop of some sort.
Note that if you did the line in red would have to be executed only once. [/edit]
s = i - 1;
if(s < 0) break;
bool valid1 = false;
if(line[s] >= 'a' && line[s] <= 'z')valid1 = true;
if(line[s] >= 'A' && line[s] <= 'Z')valid1 = true;
if(line[s] >= '0' && line[s] <= '9')valid1 = true;
if(line[s] == '_' || line[s] == '+' || line[s] == '-')valid1 = true;
if(valid1 == true)s--;
if(vaild1 == false)break;