You can use our free fax API to send faxes programmatically from the
programs that you write, by using the following [Fax API] source-code.
If you want to create your own send fax program the simple and easy way,
just write your own simple fax program and let it take advantage of our
free fax API. This API has over 30 man years of development.
In just a few minutes from now, you can write a send fax program that
takes advantage of our powerful Fax API.
If you want to write a fax program using our [Fax API] with one of our fax
programs, and want more help than what is included in this manual, you can
buy our [Extended Fax API]. The [Extended Fax API] includes many easy to
use functions and sophisticated source-code. Just call Jon Krahmer at
281-499-8246, or email him at
eMail Jon Krahmer
or
eMail ElectraSoft
and you will receive the [Extended Fax API] kit and personalized
tech-support for only $499.99.
There are two methods to use this API...
Method 1, the simplest method:
Read Item 12 - Faxing, [Convert/Forward Document to Fax and Send...]
You will need to create a comma delimited file called:
?:\faxmatic\data\DocToFax.del
Where the ? is the drive that you installed FaxAmatic on. The DocToFax.del
file can have as many lines in it as you want. One for each recipient.
Code example:
LOOP:
o CREATE the ?:\faxmatic\data\DocToFax.del file
o Copy document into ?:\faxmatic\data\DocToFax
o WAIT until FaxAmatic deletes document from
?:\faxmatic\data\DocToFax
o If done EXIT else back to LOOP
EXIT:
Method 2:
You will need to create a comma delimited file called:
?:\faxmatic\tmpfiles\send2fax.del
Where the ? is the drive that you installed FaxAmatic on. The send2fax.del
file can have as many lines in it as you want. One for each recipient.
DocToFax.del and send2fax.del Format:
3, 5 or 6 field comma delimited file with the following format:
"Y/N(header at top of fax)","Recipient","FaxNumber"
or:
"Y/N(header at top of fax)","Recipient","FaxNumber","Scheduled Date",
"Scheduled Time"
or:
"Y/N(header at top of fax)","Recipient","FaxNumber","Scheduled Date",
"Scheduled Time","Subject","Fax From Name"
HeaderYN:
A 1 character field consisting of either Y or N
Recipient:
A 31 character field consisting of the Recipient
FaxNumber:
A 46 character field consisting of a Fax Number
The next 2 fields are optional...
Scheduled Date:
A 10 character field consisting of the day to send the Fax
Scheduled Time:
A 10 character field consisting of the time to send the Fax
Example:
"Y","Jon Krahmer","1-281-499-5939"
or:
"Y","Jon Krahmer","1-281-499-5939","07-15-2002","10:30:00am"
or:
"Y","Jon Krahmer","1-281-499-5939","07-15-2001","10:30:00am","Subject","Fax From Name"
FaxAmatic must be running in the background. The
?:\faxmatic\tmpfiles\send2fax.del file must be create in the FaxAmatic
directory. Print to the ElectraSoft Print to Fax. The ElectraSoft Print to
Fax will create a ?:\esfax\fax file. FaxAmatic will see this file, convert
it to a fax and call the Send Fax box. The Send Fax will see the
?:\faxmatic\tmpfiles\send2fax.del file and instead of it's normal routine,
it will work invisibly to send the fax as per the
?:\faxmatic\tmpfiles\send2fax.del file and then delete
?:\faxmatic\tmpfiles\send2fax.del. The next time you load the Send Fax box,
it will work as normal.
Code example:
LOOP:
o CREATE the send2fax.del file
o PRINT document to: ElectraSoft Print to Fax
o WAIT until FaxAmatic deletes send2fax.del
o If done EXIT else back to LOOP
EXIT:
//============================== StartData ==============================
char szStr1024[1024];
char szSend2Fax_Del[]={ "c:\\faxmatic\\tmpfiles\\send2fax.del"};
char szFaxToThisRecipient1[1024]=
{
"\"Y\",\"ElectraSoft\",\"1-281-499-5939\""
};
char szFaxToThisRecipient2[1024]=
{
"\"Y\",\"ElectraSoft\",\"1-281-499-5939\",\"2001-06-15\",\"10:30:00am\""
};
char szFaxToThisRecipient3[1024]=
{
"\"Y\",\"ElectraSoft\",\"1-281-499-5939\",\"2001-06-15\",\"10:30:00am\"",\"Subject\""
};
int iNumOfDocsToFaxToThisRecipient=3;
//=============================== EndData ===============================
//=========================== StartPrototypes ===========================
void MyProgramsFaxProc(void);
BOOL PrintTheseDocsToElectraSoftPrintToFax(int iNumOfPrintJobs,
char* pszFaxToThisRecipient);
BOOL PrintJobToElectraSoftPrintToFax(int iJob);
BOOL WaitForElectraSoftPrintToFax(void);
BOOL CreateSend2Fax_Del(char *pszFaxToThisRecipient);
void DelayMs(DWORD dwMs);
//============================ EndPrototypes =============================
//============================== StartCode ===============================
//======================================================================
//| Example of what a call to PrintTheseDocsToElectraSoftPrintToFax may
//| look like.
//======================================================================
void MyProgramsFaxProc(void)
{
char szErrorMessageCption[]=
{
"MyProgramsFaxProc return value"
};
char szReturnedFalse[]=
{
"MyProgramsFaxProc returned FALSE"
};
char szReturnedTrue[]=
{
"MyProgramsFaxProc returned TRUE"
};
//======================================================================
//| Remove comments and replace with your application specific
//| source-code.
//======================================================================
//Init MyProgramsFaxProc() and get set vars.
if(PrintTheseDocsToElectraSoftPrintToFax( iNumOfDocsToFaxToThisRecipient,
szFaxToThisRecipient1)==TRUE)
{
::MessageBox(GetForegroundWindow(),szReturnedTrue,
szErrorMessageCption,MB_ICONSTOP|MB_OK);
}
else
{
::MessageBox(GetForegroundWindow(),szReturnedFalse,
szErrorMessageCption,MB_ICONSTOP|MB_OK);
}
}
//========================================================================
//| BOOL PrintTheseDocsToElectraSoftPrintToFax(int iNumOfPrintJobs,
//| char* pszFaxToThisRecipient);
//|=--------------------------------------------------------------------=
//| BOOL PrintTheseDocsToElectraSoftPrintToFax(int iNumOfPrintJobs,
//| char* pszFaxToThisRecipient);
//| will send(put in SendQueue) 1 or more documents to
//| pszFaxToThisRecipient.
//|
//| In this example, the FaxNumber is hard-coded to szFaxToThisRecipient1.
//|
//| You, as a programmer, will replace szFaxToThisRecipient1 with a
//| variable. If sending 1 or more documents to a list of 1 or more
//| FaxNumbers, incrementally set szFaxToThisRecipient1 to a different
//| FaxNumber in the list, and call PrintTheseDocsToElectraSoftPrintToFax
//| once for each FaxNumber that you want to send the fax/faxes to.
//========================================================================
BOOL PrintTheseDocsToElectraSoftPrintToFax(int iNumOfPrintJobs,
char* pszFaxToThisRecipient)
{
BOOL bRet=TRUE;
//====================================================================
//| LOOP
//====================================================================
for(int iJob=1;iJob<=iNumOfPrintJobs;iJob++)
{
//====================================================================
//| CREATE the send2fax.del file
//====================================================================
if(CreateSend2Fax_Del(pszFaxToThisRecipient)==FALSE)
{
bRet=FALSE;
break;
}
//====================================================================
//| PRINT document to: ElectraSoft Print to Fax
//====================================================================
if(PrintJobToElectraSoftPrintToFax(iJob)==FALSE)
{
bRet=FALSE;
break;
}
//====================================================================
//| WAIT until FaxAmatic deletes send2fax.del
//====================================================================
if(WaitForElectraSoftPrintToFax()==FALSE)
{
bRet=FALSE;
break;
}
//====================================================================
//| If done EXIT else back to LOOP
//====================================================================
}//End------for(int iJob=1;iJob<=iNumOfPrintJobs;iJob++)
//====================================================================
//| EXIT
//====================================================================
return(bRet);
}
BOOL CreateSend2Fax_Del(char *pszFaxToThisRecipient)
{
int iSend2Fax_Del;
if((iSend2Fax_Del=_open(szSend2Fax_Del,_O_CREAT|_O_TRUNC|_O_BINARY|_O_RDWR,_S_IREAD|_S_IWRITE)) < 0)
{
sprintf(szStr1024,"Could not create:\n"
"%s"
,szSend2Fax_Del);
::MessageBox(GetForegroundWindow(),
szStr1024,szAppsMsgCaption,MB_OK | MB_ICONSTOP);
return(FALSE);
}
if(_write(iSend2Fax_Del,pszFaxToThisRecipient,
(WORD)strlen(pszFaxToThisRecipient)) !=
(int)strlen(pszFaxToThisRecipient))
{
_close(iSend2Fax_Del);
return(FALSE);
}
_close(iSend2Fax_Del);
return(TRUE);
}
BOOL PrintJobToElectraSoftPrintToFax(int iJob)
{
//======================================================================
//| Remove comments and replace with your application specific
//| source-code.
//======================================================================
//if(Your Print Routine Fails)
//{
// return(FALSE);
//}
return(TRUE);
}
BOOL WaitForElectraSoftPrintToFax(void)
{
for(int iWait=0;;iWait++)
{
if(_access(szSend2Fax_Del,0)!=0)
{
break;
}
//===============================================================
//| 100 ms X 300 loops == 30000 ms == 30 seconds to time-out.
//===============================================================
DelayMs(100);
if(iWait==300)
{
if(::MessageBox(GetForegroundWindow(),
"Last print job not done."
,"Apps Caption"
,MB_DEFBUTTON1|MB_ICONQUESTION|MB_RETRYCANCEL)==IDCANCEL)
{
return(FALSE);
}
iWait=0;
}
}
return(TRUE);
}
void DelayMs(DWORD dwMs)
{
MSG msg;
struct _timeb timebCurTime;
DWORD dwCurTime,dwStopTime,dwSleepTime;
dwSleepTime=(dwMs/10);
if(dwSleepTime<1) dwSleepTime = 1;
if(dwSleepTime>100) dwSleepTime = 100;
_ftime(&timebCurTime);
dwStopTime=(((timebCurTime.time * 1000) + timebCurTime.millitm) + dwMs);
do
{
Sleep(dwSleepTime);
if(PeekMessage(&msg,NULL,0,0,PM_REMOVE)!=FALSE)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
_ftime(&timebCurTime);
dwCurTime=((timebCurTime.time*1000) + timebCurTime.millitm);
if(iTimeChangeFg>0)
{
--iTimeChangeFg;
break;
}
}while(dwCurTime < dwStopTime);
}
//=============================== EndCode ================================