I use modification of DC9.50 \Samples cpip\Active.c to succesfully get the first 100 characters of HTML code of a web page.
Active.c has this section of code:
do {
bytes_read=sock_fastread(&socket,buffer,sizeof(buffer)-1);
if(bytes_read>0) {
buffer[bytes_read] = '\0';
/*
* By using the "%s" format, if there are "%" in the buffer, printf()
* won't try to interpret them!
*/
printf("%s",buffer);
}
The line printf(“%s”,buffer); successfully displays the desired string in STDIO.
I then added a modification of DC9.50 \Samples cpip\SMTP.c after the modified Active.c code to email this string.
SMTP.c defines strings as:
#define FROM “myaddress@mydomain.com”
#define TO “myaddress@mydomain.com”
#define SUBJECT “You’ve got mail!”
/* I commented this out since the Active.c code declares
char buffer[100];
#define BODY "Visit the Rabbit Semiconductor web site.
"
“There you’ll find the latest news about Dynamic C.” */
SMTP.c then uses:
smtp_sendmail(TO, FROM, SUBJECT, BODY);
By Using smtp_sendmail(TO, FROM, SUBJECT, buffer); My program only emails the first six characters of the desired string.
I don’t understand enough about strings to get the string which printf() used successfully into smtp_sendmail().
Would you please suggest a way to do this?
Thanks!