FAXCOM and FXSCOMEX Fax programming, faxcomfxscomex
The dl that needs to be referenced. The following information is used in the early stage: FXSCOM. DLL. Now Microsoft provides the corresponding extension, and the program set is FXSCOMEX. dll.
FXSCOMEX. dll provides a follow-up method. It can be said that all fax operations are in this dll.
The following are the main methods used in Fax:
1 // define the information related to the fax recipient to be encapsulated by the fax. 2 public class FaxPeopleBean 3 {4 public string Name; 5 public string FaxNumber; 6 public string Company; 7 8 public DateTime ScheduleTime; 9 10 public FaxPeopleBean () 11 {12 ScheduleTime = QLOAParams. dtSqlDbMinValue; 13} 14}View Code
2. How to send a fax
1 public object sendFaxBatchDoc (FaxPeopleBean recipient, FaxPeopleBean sender, List <string> docList) 2 {3 bool isConnected = false; 4 FaxServer objFaxServer = null; 5 try 6 {7 objFaxServer = new FaxServer (); 8 FaxDocument objFaxDocument = new FaxDocument (); 9 Object jobIds; // a fax job id is returned after each transmission, used to monitor the sending status of this fax 10 // Connect to the fax server11 objFaxServer. connect (""); // "" means to Connect to the local machine service, you can also use other network fax server 12 isCo Nnected = true; 13 SetOutgoingQueue (objFaxServer); 14 objFaxDocument. sender. name = sender. name; 15 objFaxDocument. sender. company = sender. company; 16 objFaxDocument. sender. faxNumber = sender. faxNumber; 17 if (sender. scheduleTime! = QLOAParams. dtSqlDbMinValue) 18 {19 // Specify that the fax is to be sent at a participant time20 objFaxDocument. scheduleType = FAXCOMEXLib. FAX_SCHEDULE_TYPE_ENUM.fstSPECIFIC_TIME; 21 // CDate converts the time to the Date data type22 objFaxDocument. scheduleTime = sender. scheduleTime; 23} 24 25 // Set the fax priority26 objFaxDocument. priority = FAXCOMEXLib. FAX_PRIORITY_TYPE_ENUM.fptHIGH; 27 // 'add Recipient28 objFaxDocument. recipients. add (recipient. faxNumber, recipient. name); 29 string [] files = docList. toArray (); 30 object bodys = files; 31 objFaxDocument. bodies = bodys; 32 int result = objFaxDocument. connectedSubmit2 (objFaxServer, out jobIds); 33 return jobIds; 34} 35 finally36 {37 if (isConnected & objFaxServer! = Null) 38 {39 objFaxServer. Disconnect (); 40} 41} 42}
3. It is used to set some fax attributes. It can be set only after connection.
Public void SetOutgoingQueue (FaxServer objFaxServer) {FaxOutgoingQueue objFaxOutgoingQueue; // 'get the outgoing queue object objFaxOutgoingQueue = objFaxServer. folders. outgoingQueue; // 'refresh the queue object objFaxOutgoingQueue. refresh (); objFaxOutgoingQueue. retries = 10; // after 10 Retries, The objFaxOutgoingQueue will not occur again. retryDelay = 1; // The Branding property is a Boolean value that indicates whether the fax service generates a brand (banner) // at the top of outgoing fax transmissions. A brand contains transmission-related information, such as the transmitting // station identifier, date, time, and page count. objFaxOutgoingQueue. branding = true ;}
4. Cancel sending a fax.
Public void CancelOutgoingQueue (string faxJobid) {FaxServer objFaxServer = new FaxServer (); FaxOutgoingQueue failed; FaxOutgoingJob failed; // 'connect to the fax server objFaxServer. connect (""); // 'get the outgoing queue object objFaxOutgoingQueue = objFaxServer. folders. outgoingQueue; // 'refresh the queue object objFaxOutgoingQueue. refresh (); try {objFaxOutgoingJob = (FaxOutgoingJob) objFaxOutgoingQueue. getJob (faxJobid); // if no exception is found, the objFaxOutgoingJob will occur. cancel ();} catch {} objFaxServer. disconnect ();}
5. You need to monitor the fax sending status
FAXCOMEXLib.FaxServer _faxServer= new FaxServer(); _faxServer.Connect(""); _faxServer.OnOutgoingJobChanged +=FaxServer_OnOutgoingJobChanged;
_faxServer.ListenToServerEvents( FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetFXSSVC_ENDED | FAXCOMEXLib.FAX_SERVER_EVENTS_TYPE_ENUM.fsetOUT_QUEUE;
6. The monitoring method is here
Public void Merge (FAXCOMEXLib. IFaxServer pFaxServer, string bstrJobId, FAXCOMEXLib. IFaxJobStatus pJobStatus) {// you can obtain the fax information in real time based on the pJobStatus enumeration. The operation code can be written here
}