[ back to toc ]

SMTP - displaying message body

Date: 2002/03/04 16:25

Q:
Hi,

Am writing a SMTP client in VC++ 6.0 using winsock commands. Everything is
fine except that the message of the email is not being displayed.

Who its from, who its to, the subject are all displayed but I cannot
display the actual message. This is the code that I have used.

i=connect(S,(struct sockaddr *) &A,sizeof(A));
i=recv(S,R,30000,0);

strcpy(R,"EHLO\r\n");
i=send(S,R,strlen(R),0);

i=recv(S,R,30000,0);

strcpy(R,"MAIL FROM:<cian.reynolds@prag.co.uk>\r\n");

i=send(S,R,strlen(R),0);

i=recv(S,R,30000,0);

strcpy(R,"RCPT TO:<cian.reynolds@prag.co.uk>\r\n");

i=send(S,R,strlen(R),0);

i=recv(S,R,30000,0);

strcpy(R,"DATA\r\n");
i=send(S,R,strlen(R),0);

i=recv(S,R,30000,0);

strcpy(R,"To: *NAME-DELETED* *NAME-DELETED*\r\n");
i=send(S,R,strlen(R),0);

strcpy(R,"FROM: cian.reynolds@prag.co.uk\r\n
i=send(S,R,strlen(R),0);

strcpy(R,"SUBJECT: HELP ERROR!!!!!\r\n");
i=send(S,R,strlen(R),0);

strcpy(R,"this is the message but i can't see it in the body of the
email!!!\r\n");
i=send(S,R,strlen(R),0);

strcpy(R,".\r\n");
i=send(S,R,strlen(R),0);

i=recv(S,R,30000,0);

strcpy(R,"QUIT\r\n");
i=send(S,R,strlen(R),0);

i=recv(S,R,30000,0);
return 0;

I hope you can help as this one has been driving me crazy.

Cheers,
*NAME-DELETED*
A:
I am almost sure that you do not print an empty line between the header
and the body of the mail.

regards,
Peter
Q:
Hi Peter,

Could you please explain what you mean. I can't see where I have a written
an empty line.

Cheers,

*NAME-DELETED*

A:
Actually where you have NOT:

strcpy(R,"SUBJECT: HELP ERROR!!!!!\r\n");
i=send(S,R,strlen(R),0);

strcpy(R,"\r\n"); //this one you miss!!!
i=send(S,R,strlen(R),0);

strcpy(R,"this is the message but i can't see it in the body of the
email!!!\r\n");

regards,
Peter

[ back to toc ]