gpt4 book ai didi

c# - FaxComExLib 的问题

转载 作者:太空宇宙 更新时间:2023-11-03 22:08:30 25 4
gpt4 key购买 nike

我可以使用 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 = "someone@example.com";
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 = "someone@microsoft.com";
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();

Unable to cast COM object of type 'System.__ComObject' to interface type 'FAXCOMEXLib.FaxServer'.

当我这样做时:FaxServer objFaxServer = new FaxServerClass();我什至无法编译该行。它显示:Interop type 'FAXCOMEXLib.FaxServerClass' cannot be embedded。请改用适用的接口(interface)。

所以,我在那条线上停了下来:/

顺便说一句。基本上,我想实现一个类来发送传真并查看已发送消息的状态。如果有人发送整个准备好使用的类(class),我将非常高兴。

请帮帮我,

最佳答案

When I do: FaxServer objFaxServer = new FaxServerClass(); I can't even compile that line

关于 COM 对象的奇怪之处在于,接口(interface)有时就像它们具有构造函数一样:

FaxServer objFaxServer = new FaxServer();

这是正确的行。我有它,它可以工作。互操作可能有问题。

关于c# - FaxComExLib 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7554706/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com