General information
Category:
Windows API functions
If finally had time to look this up. This code will
NOT send a cover page (unless you want it to, you will have to
pass it the entire CVP path if so). This works regardless of
the users personal winfax configuration.
To send a fax without a foxpro report (attachment only), without user
intervention, use:
DO SendFax WITH .F.,.F.,"","555-1212","Company","Contact","Subject","C:\FILENAME.TXT",""
lShowSendScreen = .T. will give the user a chance to customize before sending.
lRunReport = .T. Runs a foxpro report file (cReportName) to winfax
** Begin Code
PROCEDURE SendFax
PARAMETERS lShowSendScreen, lRunReport, cReportName, CallNumber, cCompany, cContact, cSubject, cAttachFile, cCoverPage
DECLARE integer GetWindowsDirectory IN Win32API string @lcBuffer, integer nBufferSize
DECLARE integer FindWindow IN Win32API string a, string b as c
DECLARE INTEGER GetPrivateProfileString IN Win32API AS GetPrivStr ;
String cSection, String cKey, String cDefault, String @cBuffer, ;
Integer nBufferSize, String cINIFile
lcBuffer = SPACE(255) + CHR(0)
=DDESETOPTION("TIMEOUT",30000)
=DDESETOPTION("SAFETY",.F.)
* this section changes the windows default printer to winfax..
Success = APRINTER(PLIST)
IF Success = 0
=MessageBox('There Are No Printers Installed In Windows',16,'Error')
RETURN .F.
ENDIF
IsFound = .F.
FOR x = 1 to Success
IF PLIST(x,1) = 'WinFax'
SET PRINTER TO NAME (PLIST(x,1))
IsFound = .T.
ENDIF
ENDFOR
IF IsFound = .F.
=MessageBox('Winfax Pro is not installed. The program works will all Winfax Pro version 3.x and higher. You will need to install Delrina(r) Winfax Pro on your computer.',16,'Winfax Not Available')
RETURN .F.
ENDIF
lcBuffer = SPACE(100) + CHR(0)
lcrecipient = 'recipient("' + ;
CallNumber + ;
'","","","' + ;
rtrim(cContact) + ;
'","' + ;
rtrim(cCompany) + ;
'","' + ;
rtrim(cSubject) + ;
'"," "," ")'
* This section launches the faxmng.exe program
lWinfax = FindWindow(0,'Delrina Winfax PRO') && WIN32 API routine to see if app is running
lcBuffer = REPLICATE(CHR(0),144)
IF lWinfax == 0
lnnumbytesreturned = GetPrivStr('Winfax','ExePath','',@lcBuffer,LEN(lcBuffer),'WIN.INI')
IF (lnnumbytesreturned > 0) AND ;
(FILE(LEFT(lcBuffer, lnnumbytesreturned) + 'FAXMNG.EXE'))
FaxMgrPath = LEFT(lcBuffer, lnnumbytesreturned)+'FAXMNG.EXE'
WAIT WINDOW 'Winfax Link In Progress...' NOWAIT
RUN /N7 &FaxMgrPath
ELSE
=MessageBox('Could Not Locate WinFax (FAXMNG.EXE) in WIN.INI; Check the [WinFax] section for the entry ExePath =',16,'WinFax DDE Error')
RETURN .F.
ENDIF
ENDIF
ReCount = 0
ChanNum = -1
DO WHILE ReCount < 5 And ChanNum < 0
ChanNum = DDEINITIATE("FAXMNG",'TRANSMIT')
IF ChanNum < 0
ReCount = ReCount + 1
=INKEY(2)
ENDIF
ENDDO
IF ChanNum < 0
=MessageBox('Winfax Is Not Responding To Requests. PRINT your fax to a printer instead.',0,'Winfax DDE Error')
RETURN .F.
ENDIF
=DDEPOKE(ChanNum,"SendFAX",(lcrecipient))
IF !empty(cAttachFile)
ToDo = 'attach(' + chr(34) + rtrim(cAttachFile) + chr(34) + ')'
=DDEPOKE(ChanNum,"SendFAX", (ToDo))
ENDIF
IF !EMPTY(cCoverPage)
=DDEPOKE(ChanNum,"SendFAX","SetCoverPage('" + cCoverPage + "')")
ENDIF
IF lShowSendScreen
=DDEPOKE(ChanNum,"SendFAX","showsendscreen('1')") && User can add other documents; otherwise fax without user intervention
ENDIF
IF lRunReport
REPORT FORM (cReportName) TO PRINTER NOCONSOLE && print trigger send operation
ELSE
=DDEPOKE(ChanNum,"SendFAX","SendFaxUI") && Tell winfax send without app printing
ENDIF
=DDETERMINATE(ChanNum)
RETURN .T.
Previous
Next
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only