Perhaps R's function readLines is the right thing for you. AFAIK it returns a vector of strings containing the lines of th email. Or you could try to count the occurence of the newline character '\r' (Unicode 0xA) Regards!