FAXCOMLib.FaxServer fxsvr = new FAXCOMLib.FaxServer(); FAXCOMLib.FaxDoc fxdoc = (FAXCOMLib.FaxDoc)fxsvr.CreateDocument(Application.StartupPath + "\\scratch.doc"); try { fxsvr.Connect(null); // null for local fax server otherwise a computername } catch (Exception ex ) { MessageBox.Show( ex.ToString()); } fxdoc.FileName = Application.StartupPath + "\\scratch.doc"; fxdoc.FaxNumber = theNumber; fxdoc.RecipientName = theFaxParty; try { fxdoc.Send(); } catch ( Exception ex ) { MessageBox.Show( ex.ToString()); } fxsvr.Disconnect();If you don't mind doing COM Interop you can leverage the fax service in Windows 2000/XP. You start by adding a COM reference to FAXCOM.DLL (usually under C:\WINNT\SYSTEM32), then create two objects: FaxServer and FaxDoc.You use the FaxServer object to connect to your server, and then create FaxDoc object passing the document you want to fax. At this point you set the number to dial, send the fax, and disconnect from the server.You can find the Fax Service Extended COM API documentation here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fax/faxabout_699l.asp
Using Windows Fax Service of Windows 2000 in C#http://www.dotnetspider.com/kb/Article680.aspx
2003下的控制面板里面有打印机和传真,看看是否那里提供了。本人2003下没有设置过。下面是一段代码 using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; using FAXCONTROLLib;public void FuncName() { FAXCOMEXLib.FaxServerClass oFaxServerClass = new FAXCOMEXLib.FaxServerClass() ; oFaxServerClass.Connect("Server Name") //Such As "Damavand"; FAXCOMEXLib.FaxDocumentClass oFaxDoc = new FAXCOMEXLib.FaxDocumentClass(); oFaxDoc.Body = MyFileName // Such As @"E:\1.tif"; oFaxDoc.DocumentName = "Salam"; oFaxDoc.Recipients.Add("15" , "My Recipient Name"); oFaxDoc.ConnectedSubmit(oFaxServerClass); oFaxServerClass.Disconnect(); }
using FAXCONTROLLib; 出错啊! 是不是应该用 using FAXCOMLib? 用FAXCOMLib的话,出异常 Retrieving the COM class factory for component with CLSID {D73733C8-CC80-11D0-B225-00C04FB6C2F5} failed due to the following error: 80040154.
FAXCOMLib.FaxDoc fxdoc = (FAXCOMLib.FaxDoc)fxsvr.CreateDocument(Application.StartupPath + "\\scratch.doc"); try
{
fxsvr.Connect(null); // null for local fax server otherwise a computername
}
catch (Exception ex )
{
MessageBox.Show( ex.ToString());
} fxdoc.FileName = Application.StartupPath + "\\scratch.doc";
fxdoc.FaxNumber = theNumber;
fxdoc.RecipientName = theFaxParty; try
{
fxdoc.Send();
}
catch ( Exception ex )
{
MessageBox.Show( ex.ToString());
} fxsvr.Disconnect();If you don't mind doing COM Interop you can leverage the fax service in
Windows 2000/XP. You start by adding a COM reference to FAXCOM.DLL (usually
under C:\WINNT\SYSTEM32), then create two objects: FaxServer and FaxDoc.You use the FaxServer object to connect to your server, and then create
FaxDoc object passing the document you want to fax. At this point you set
the number to dial, send the fax, and disconnect from the server.You can find the Fax Service Extended COM API documentation here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/fax/faxabout_699l.asp
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using FAXCONTROLLib;public void FuncName()
{
FAXCOMEXLib.FaxServerClass oFaxServerClass = new FAXCOMEXLib.FaxServerClass()
;
oFaxServerClass.Connect("Server Name") //Such As "Damavand";
FAXCOMEXLib.FaxDocumentClass oFaxDoc = new FAXCOMEXLib.FaxDocumentClass();
oFaxDoc.Body = MyFileName // Such As @"E:\1.tif";
oFaxDoc.DocumentName = "Salam";
oFaxDoc.Recipients.Add("15" , "My Recipient Name");
oFaxDoc.ConnectedSubmit(oFaxServerClass);
oFaxServerClass.Disconnect();
}
这过不去,请赐教
应改为fxsvr.Connect(FaxServerName);
FaxServerName用你的机器名就行了
出错啊!
是不是应该用
using FAXCOMLib?
用FAXCOMLib的话,出异常
Retrieving the COM class factory for component with CLSID {D73733C8-CC80-11D0-B225-00C04FB6C2F5} failed due to the following error: 80040154.