I have done a solution for a client faxing whole day and serializing numbers on faxes and archiving them in VFP 8.0
I rewrote it 2 years ago to fax and email, now i dropped the stupid fax. Thing includes a KANBAN system even calculating how many stock items to order. Then sit back and have coffee and a donut.
Below an old commented example with comments, it is a TAPI call.
*Close All
Public V1, V2
Set Safety Off
x=Createobject('faxserver.faxserver')
lcMachine = "\\"+Getwordnum(Sys(0),1) && somewhat simpler code; wOOdy
x.Connect( lcMachine )
fj = x.getjobs()
*?fj.Count && Prints "0"
fj=.F.
* Show the fax drivers loaded on this machine:
fp = x.getports()
*?fp.Count
*WAIT message fp.Item(1).Name WINDOW AT 10,20
*?fp.Item(1).canmodify
*?fp.Item(1).rings
*?fp.Item(1).Send
*?fp.Item(1).tsid
*?fp.Item(1).csid
*?fp.Count
Select b
Go Bottom
Store serialnr To V2
Go Top
Store serialnr To V1
Do While .Not. Eof()
* Create a fax document
FD = x.createdocument("filename")
FD.faxnumber = ALLTRIM(faxnr)
FD.displayname = 'KANBAN Fax '+Alltrim(Str(V1))+'-'+Alltrim(Str(V2))
* Before running this program, create a word document
* called SampleFax.doc... The TAPI interface will automatically
* invoke the registered shell "Print" command on it.
Store Recno() To tel
Store "kanban"+Alltrim(Str(V1))+'-'+Alltrim(Str(V2))+".txt" To noemer
Report Form kanban Noconsole To File &noemer
*For Recno()=tel
FD.filename = Fullpath(noemer)
FD.sendcoverpage = .F.
* Send it Off!
* (you should see Foxpro report running briefly and print the document,
* then the Microsoft Fax icon should show up in the system tray
* and try to send the fax!)
FD.Send
*clean up (probably should wait a bit before this)
Inkey(1)
*FD = .F.
*x = .F.
*Do While .Not. Eof()
*Go tel
*Skip
*Enddo
Enddo
Set Safety Off
Public faxstr, faxstr2, sernr, sernr2, nr, old, v4, oudnaam, nieuwnaam
Store '"'+Sys(5)+Sys(2003)+'"' To huid
*STORE sys(5)+SYS(2003)+'\' TO tr
Store "c:\kanban\*.*" To faxstr
Store '"c:\kanban"' To faxstr2
*Use faxes2 exclusive
Select c
Do While .T.
Adir(fa,faxstr)
Zap
Append From Array fa
Replace All filename With Lower(filenaam)
REPLACE ALL tijd2 WITH CTOT(DTOC(datum)+' '+tijd)
INDEX ON tijd2 TO faxes2
Go Bottom
*line below to check for validated renaming
WAIT "Laatst verzonden fax= "+filename WINDOW AT 10,20 TIMEOUT 1
Store '"c:\kanban\'+Alltrim(filename)+'"' To old
If Left(filename,5)='faxnr' .Or. Lower(Left(filenaam,5))='start'
LOOP
ELSE
If Left(filename,5)<>'faxnr' .Or. Lower(Left(filenaam,5))<>'start'
Store 'faxnr'+Alltrim(Str(V1))+'-'+Alltrim(Str(V2))+'.tif' To sernr
Store '"'+'faxnr'+Alltrim(Str(V1))+'-'+Alltrim(Str(V2))+'.tif'+'"' To sernr2
Replace filenaam With sernr
WAIT "Now sent fax= "+filename WINDOW AT 10,20 TIMEOUT 3
exit
Endif
ENDIF
Enddo
Set Default To &faxstr2
Rename &old To &sernr2
Set Default To &huid