需要引用的dl,如下信息,早起使用的是FXSCOM.DLL,現在微軟提供了相應的擴展,其程序集為,FXSCOMEX.dll

FXSCOMEX.dll 提供跟加健全的方法,可以說所有關于傳真的操作都在這個dll中。
以下是傳真中使用的主要方法:

1 //定義傳真需要封裝的傳真人相關的信息 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 Code2. 發送傳真的方法
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;//每次發送后,都會返回一個傳真作業id,用于監控此傳真的發送情況10 //Connect to the fax server11 objFaxServer.Connect(""); //""代表連接到本地機器服務,也可以使用其它網絡傳真服務器12 isConnected = 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 particular 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 the 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. 用于設置傳真的一些屬性,必須連接過后才可以設置
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; //重試10次后不再發生 objFaxOutgoingQueue.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. 取消某個傳真的發送
public void CancelOutgoingQueue(string faxJobid) { FaxServer objFaxServer = new FaxServer(); FaxOutgoingQueue objFaxOutgoingQueue; FaxOutgoingJob objFaxOutgoingJob; //'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); //找不到時會發生異常 objFaxOutgoingJob.Cancel(); } catch { } objFaxServer.Disconnect(); }5. 需要對傳真發送情況進行監控
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. 監控的方法在這里
public void FaxServer_OnOutgoingJobChanged(FAXCOMEXLib.IFaxServer pFaxServer, string bstrJobId, FAXCOMEXLib.IFaxJobStatus pJobStatus) { //根據pJobStatus 枚舉可以實時的獲取,傳真的發生情況,具體的操作代碼可以寫作這里}
新聞熱點
疑難解答