SMTPSendFile doesn't send whole file
Keywords: SMTPSendFile null characters null strings
Question:
I'm trying to have backup logs automatically sent via e-mail. What's happenning is that it's sending the first line of the file, and that's it. With a hex editor, I found that immediately following the line it does send is:00 0D 0A 00 0D 0A(space, CRLF, space, CRLF - I think)By taking the spaces out, the whole file goes. Does winbatch think it's the EOF when it sees that pattern?
Answer:
That's00 0D 0A 00 0D 0A(*NULL*, CRLF, *NULL*, CRLF - I think)(Space is a 20 )
The *NULL* signifies end of data. Its considered binary information making it a non-text file and beyond the capability of the SMTP function.
Presumably you could "massage" the file prior to email to remove the null characters. How big is the file. For not-too-big files you could add this code....
*NOTE: TOTALLY UNDEBUGGED*
fn="C:\temp\yourbackup.log" fs=FileSize(fn) bb=BinaryAlloc(fs) BinaryRead(bb,fn) fsX=fs-1 for xx=0 to fsX byte=BinaryPeek(bb,xx) if byte==0 then BinaryPoke(bb,xx,32) next BinaryWrite(bb,fn) BinaryFree(bb) ;Now do the SMTP stuffNote 32 decimal == hex 20 == ascii space
Article ID: W12680Filename: SMTPSendFile of File Containing Null Chars.txt