Hello,
How to write a fax program to send a fax page?
Printable View
Hello,
How to write a fax program to send a fax page?
You can write a fax program that requires MS Exchange to be running in the background...you need to do something like this.
In you .h file
#include <mapi.h>
typedef ULONG (CALLBACK* LPFNMAPISENDMAIL) (ULONG,ULONG,MapiMessage*,FLAGS,ULONG);
in your public definitions
//faxing
LPFNMAPISENDMAIL m_lpfnMAPISendMail;
HINSTANCE m_hlibMAPI;
MapiRecipDesc mrd[1];
in your .cpp file
in your OnInit
m_hlibMAPI = AfxLoadLibrary("mapi32.dll");
m_lpfnMAPISendMail = (LPFNMAPISENDMAIL) GetProcAddress(m_hlibMAPI,"MAPISendMail");
when you want to send fax
if (GetModuleHandle("exchng32.exe"))
{
MapiRecipDesc mrd[1];
mrd[0].ulReserved = 0;
mrd[0].ulRecipClass = MAPI_TO;
mrd[0].lpszName="Recipient Name";
mrd[0].lpszAddress="FAX:249-8045";//phone#
mrd[0].ulEIDSize=0;
mrd[0].lpEntryID = NULL;
MapiMessage note= { 0,
"Message to be displayed in note sec",
NULL,
NULL,
NULL,
NULL,
0L,
NULL,
1,
mrd,
0L,
NULL};
ULONG err = m_lpfnMAPISendMail(0L,0L, ¬e, MAPI_LOGON_UI, 0L);
}
else
{
MessageBox("Error while attempting to fax ... Microsoft Exchange is not running","Error");
}
you can look up the parameters of the call to see what the are all for
in you destructor
AfxFreeLibrary(m_hlibMAPI);
Hello czieler,
Thanx for ur code to send a fax. But if I don't have MS-Exchange, how can I do just using a modem ? If u can help me with a code, it will be very useful.
Why reinvent the wheel? I think you would be better off getting a third party library. Unless you are familiar with that type of programming (serial communications), what happens if someone posts you code that works half the time? Who is going to diagnose the problems? Very few if any one here could help out if you have a 3000 line program that sends faxes and you don't know where to start looking if there are problems.
You can get the BlackIce Fax library. There are others. Shop around.
Regards,
Paul McKenzie