Hi,
I'm trying to make a small e-mail client that will allow me to browse through the messages on my account and delete them if I wish. I've managed to get Winsock up and running (no easy feat, I can tell you ) and the server accepts my username and password.
What I want to do then is to go through each message on the server, get the Subject line and add it to a list box. My code for getting the Subject line is thus:-
Code:
(int iStatus = current position in retrieval process (5 = receiving messages))
(char *g_szBuffer = input buffer from recv())
(char g_szTemp[256] = temporary string)
(HWND g_hwndList = window handle for list box)
(long lCurMsg = current message being received)
(long lCount = total number of messages)
if (iStatus == 5)
{
char *cSubjectPos, *cSubjectEnd;
cSubjectPos = strstr(g_szBuffer, "Subject:");
if (cSubjectPos != NULL)
{
cSubjectEnd = strchr(cSubjectPos, '\r')
if (cSubjectEnd != NULL)
{
*cSubjectEnd = '\0';
SendMessage(g_hwndList, LB_ADDSTRING, 0, (LPARAM)cSubjectPos+9);
wsprintf(g_szTemp, "RETR %ld\r\n", lCurMsg);
lCurMsg++;
send(g_Socket, g_szTemp, strlen(g_szTemp), 0);
if (lCurMsg > lCount)
iStatus = 6;
}
}
}
Unfortunately, while the "Subject:" string is found, the carriage return character isn't, for some reason. Has anyone else done this or can suggest a different way of doing it?
Or even show me what I'm doing wrong, that'd be nice