我可以使用FAXCOMLib成功传真邮件。现在我尝试使用FAXCOMEXLib,但是我有问题:/
这是代码(来自MSDN VB示例):
try
{
FaxServer objFaxServer = new FaxServer();
FaxDocument objFaxDocument = new FaxDocument();
object JobID;
objFaxServer.Connect(Environment.MachineName);
objFaxDocument.Body = "test.bmp";
objFaxDocument.DocumentName = "Test name";
objFaxDocument.Recipients.Add("xxxxxxx", "Name");
objFaxDocument.AttachFaxToReceipt = true;
objFaxDocument.CoverPageType = FAXCOMEXLib.FAX_COVERPAGE_TYPE_ENUM.fcptSERVER;
objFaxDocument.CoverPage = "generic";
objFaxDocument.Note = "Here is the info you requested";
objFaxDocument.ReceiptAddress = "[email protected]";
objFaxDocument.ReceiptType = FAXCOMEXLib.FAX_RECEIPT_TYPE_ENUM.frtMAIL;
objFaxDocument.ScheduleType = FAXCOMEXLib.FAX_SCHEDULE_TYPE_ENUM.fstNOW;
objFaxDocument.Subject = "Today's fax";
objFaxDocument.Sender.Title = "Mr.";
objFaxDocument.Sender.Name = "Bob";
objFaxDocument.Sender.City = "Cleveland Heights";
objFaxDocument.Sender.State = "Ohio";
objFaxDocument.Sender.Company = "Microsoft";
objFaxDocument.Sender.Country = "USA";
objFaxDocument.Sender.Email = "[email protected]";
objFaxDocument.Sender.FaxNumber = "12165555554";
objFaxDocument.Sender.HomePhone = "12165555555";
objFaxDocument.Sender.OfficeLocation = "Downtown";
objFaxDocument.Sender.OfficePhone = "12165555553";
objFaxDocument.Sender.StreetAddress = "123 Main Street";
objFaxDocument.Sender.TSID = "Office fax machine";
objFaxDocument.Sender.ZipCode = "44118";
objFaxDocument.Sender.BillingCode = "23A54";
objFaxDocument.Sender.Department = "Accts Payable";
JobID = objFaxDocument.ConnectedSubmit(objFaxServer);
MessageBox.Show(("The Job ID is :" + JobID.ToString()),"Finished");
objFaxServer.Disconnect();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString() + ". " + ex.ToString(), "Exception");
}
该行引发异常:FaxServer objFaxServer = new FaxServer();
无法将类型为“ System .__ ComObject”的COM对象转换为接口类型为“ FAXCOMEXLib.FaxServer”。
当我这样做时:
FaxServer objFaxServer = new FaxServerClass();
我什至无法编译该行。它显示:
Interop type 'FAXCOMEXLib.FaxServerClass' cannot be embedded. Use the applicable interface instead.
所以,我在那行停了下来:/
顺便说一句。基本上,我想实现一个将发送传真并查看已发送消息状态的类。如果有人派出一个完整的随时可用的课程,我将非常高兴。
请帮我,
最佳答案
当我这样做时:FaxServer objFaxServer = new FaxServerClass();我什至不能
编译那条线
关于COM对象的怪异之处在于,接口有时会像具有构造函数那样工作:
FaxServer objFaxServer = new FaxServer();
那是正确的线。我在我身上有它,它可以工作。互操作可能有问题。
关于c# - FaxComExLib问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7554706/