WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

SMTP Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

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's
00 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 stuff 
Note 32 decimal == hex 20 == ascii space
Article ID:   W12680
Filename:   SMTPSendFile of File Containing Null Chars.txt
File Created: 1999:04:15:16:48:54
Last Updated: 1999:04:15:16:48:54