I read text from a file, character by character, into a CString. I then put the CString into the email body via the addtext() function.
Everyhting workes great, except when I use a large text file (1000+ chars) I get extra carraige returns in the body of my email. Infact, the carriage returns seem to be occuring every 1000 characters approximatly. If I resend the same text, the carraige returns always occur at the same places.
for example:
"You will learn a lot more by attempting the problem yourself and asking for help with the bits that are not working and you will beNotice the carraige return after "be" for no reason, thats what my emails look like every 1000ish chars.
more likely to get help if you appear to have made an attempt at the problem yourself."
To be specific, all my text handling code is of the "T" varient, as in _tprintf, TCHAR, _T("Some text"), etc. and _UNICODE is defined. I am using VS2005. I have tested the resulting emails in Outlook 2003 and Gmail, both giving the same results. The text files I am testing with are .txt ascii files.
Im pretty sure the problem isnt with reading the file because:
A) if I print the CString "body" to the screen or inspect it in the debugger it is fine, no added carriage returns.
B) if I pass addtext() a really long static string I get the problem, ie: Msg.addtext(_T("A very long string.............."));
I have no idea what Im doing wrong...
here is a snippet of my code (very condensed):
CoInitialize(NULL);
CMimeMessage emailMsg;
wfstream BodyFile;
TCHAR character;
CString body;
BodyFile.open(SubParameter, ios_base::in);
while (BodyFile.good())
{
character = BodyFile.get();
if (!BodyFile.eof())
{
_tprintf(&character);
body.AppendChar(character);
}
}
BodyFile.Close();
emailMsg.AddText(body);
CSMTPConnection conn;
if(conn.Connect(_T("SomeDomain.com")))
{
conn.SendMessage(emailMsg));
conn.Disconnect();
}