1

I have tried the code below for sending fax:

uses
  ComObj, ActiveX, FAXCOMEXLib_TLB;

procedure TForm1.Button1Click(Sender: TObject);
var
  I: Integer;
  JobIDs: OleVariant;
  FaxServer: IFaxServer2;
  FaxDocument: IFaxDocument2;
begin
  try
    FaxServer := CoFaxServer.Create;
    FaxServer.Connect('');
    FaxDocument := CoFaxDocument.Create;
    FaxDocument.Body := 'd:\Document.pdf';
    FaxDocument.DocumentName := 'Document name';
    FaxDocument.Recipients.Add('+1 (425) 555-4567', 'Bill');
    FaxDocument.Sender.Name := 'Bob';
    FaxDocument.Sender.BillingCode := '23A54';
    FaxDocument.Sender.Department := 'Accts Payable';
    FaxDocument.Sender.FaxNumber := '+972 (4) 555-9070';
    JobIDs := FaxDocument.ConnectedSubmit(FaxServer);

    for I := VarArrayLowBound(JobIDs, 1) to VarArrayHighBound(JobIDs, 1) do
      ShowMessage('Job ID: ' + VarArrayGet(JobIDs, [I]));
  except
    on E: EOleSysError do
      ShowMessage(
        Format('Sending of the fax failed! %s [%d]', [E.Message, E.ErrorCode])
      );
  end;
end;

What I was trying to do was get the job status for the fax sent. I have tried to add

var
  FaxJobStatus: IFaxJobStatus;
.....

FaxJobStatus := CoFaxJobStatus.Create;

compiled the source code and found no error but after executing the code, it fails at FaxJobStatus := CoFaxJobStatus.Create saying "class not registered".

4

1 回答 1

1

IFaxJobStatus 文档

您不创建 FaxJobStatus 对象。当您实现 IFaxServerNotify::OnIncomingJobChanged 或 IFaxServerNotify::OnOutgoingJobChanged(包括 FaxJobStatus 类型的参数)时,它会作为通知的一部分接收。当事件发生并调用实现的函数时,您会收到包含动态信息的此对象。

因此,您必须注册IFaxServerNotify.OnIncomingJobChangedorIFaxServerNotify.OnOutgoingJobChanged事件。收到事件后,您将获得 FaxJobStatus 对象并可以读取其Status属性。

于 2014-07-05T15:06:10.103 回答